Any help would be appreciated. I have a simple form (frmSoapPelletCoA) with a 'Report' button that I would like to print preview a single record set into a report (rptSoapPelletCoA) based on the 'Material IDH'(text field). It should go through a query named qryCoAHistory. The following code results in an Enter Parameter Value: Material_IDH pop up. I would like it to automatically go through to the report. - Private Sub cmdReportPrintPreview_Click()
-
On Error GoTo Err_cmdReportPrintPreview_Click
-
-
Dim strDocName As String
-
Dim strWhere As String
-
strDocName = "rptSoapPelletCoA"
-
strWhere = "Material_IDH='" & Me.Material_IDH.Value & "'"
-
DoCmd.OpenReport strDocName, acPreview, , strWhere
-
-
-
Exit_cmdReportPrintPreview_Click:
-
Exit Sub
-
-
Err_cmdReportPrintPreview_Click:
-
MsgBox Err.Description
-
Resume Exit_cmdReportPrintPreview_Click
-
-
End Sub
5 1389 zmbd 5,501
Expert Mod 4TB
You do not state what, if anything, you are getting now.
Please look at line 7 strWhere = "Material_IDH='" & Me.Material_IDH.Value & "'"
Unless Me.Material_IDH.Value is a string/text then you can and should remove the single quotes strWhere = "Material_IDH=" & Me.Material_IDH.Value
Also you have a "Material_IDH pop up" you need to go back to the table/query that the report is based on and do two things:
1) Check that the field is actually there (you'd be amazed howmany times in a query the field was omitted by accident!)
I don't suspect this is the issue; however, easy enough to double check.
2) Check that "Material_IDH" is actually spelled that way...usually, now days, case doesn't matter; however, I try to match the case anyway (old school habits are hard to break).
Insert between line7 and line8 debug.print "strWhere = " & strWhere
run your code press <ctrl><g> the immediates window in the VBE will open, please take note of the resulting string. and post it back here.
If the Report is based on a query, please open the query in design view, right click on an empty space in the tables area, selct SQL view from the popup.
Paste that text into a post in this thread, select the pasted text in the post and click on the [CODE/] formatting button in the toolbar.
Material_IDH is a text field.
Yes, Material IDH is there and spelled correctly.
<ctrl><g> came up with nothing in the Immediate window.
The report is based on a query. See below: - SELECT tblCoAHistory.[Material IDH]
-
, tblSoapPelletSpecs.Description
-
, tblCoAHistory.[Production Date]
-
, tblCoAHistory.[Batch Code]
-
, tblCoAHistory.[NaCl,%]
-
, tblCoAHistory.[Glycerin,%]
-
, tblCoAHistory.[Sorbitol,%]
-
, tblCoAHistory.[Alkalinity,%]
-
, tblCoAHistory.[Free Fatty Acid,%]
-
, tblCoAHistory.[Moisture,%]
-
, tblCoAHistory.Color
-
, tblCoAHistory.Odor
-
, tblCoAHistory.[Foreign Matter]
-
FROM tblSoapPelletSpecs
-
INNER JOIN tblCoAHistory
-
ON tblSoapPelletSpecs.[Material IDH]
-
= tblCoAHistory.[Material IDH];
zmbd 5,501
Expert Mod 4TB
Material_IDH is a text field.
Sigh, was hoping for the simple fix :)
Yes, Material IDH is there and spelled correctly.
As I thought; however, it is such a common issue that it's always worth a double check.
<ctrl><g> came up with nothing in the Immediate window.
(?_?)
You did place: debug.print "strWhere = " & strWhere
between lines 7 and 8 first?
You should have at least seen "strWhere = "
SQL: "SELECT tblCoAHistory.[Material IDH], "
You have an underscore in Line7 of the code block in post#1
You do not have an underscore here... this would be a typo and why you are getting the prompt.
Change line7 to: "Material IDH='" & Me.Material_IDH.Value & "'"
Let us know what happens.
As I mentioned, the typo is one of the most common issues.
Please double check all of your field references in the code vs. the field names in the SQL.
BTW: Although is now allowed in code and SQL for many of the newer versions of software, it is still advisable to use the underscore and not spaces in field names and in general to not use anything except alphanumerics: Access 2007 reserved words and symbols AllenBrowne- Problem names and reserved words in Access
Using that comma and the percent sign in the field names will come back and haunt you... in the very near future!
Pookaro85,
You might also try to specify the column.
If your combobox has a different bound column than the value you're trying to run the report on, you may have trouble. It might be safer to use: - strWhere = "Material_IDH='" & Me.Material_IDH.Column(1) & "'"
Where column 1 is the actual value you want to use for the displayed value.
Gunner
zmbd 5,501
Expert Mod 4TB
The solution offered by dgunner71 is not needed:
There is no need to refer to the specfic column IF the control has the bound column property set then the value of the control is the value of the bound columm. Doing this adds an additional level of complication that is unneeded.
Furthermore, this reference will not fix the issue as the field is still mis-spelled.
-z
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Andy |
last post by:
Hi All.
I'm working for a company that has set out a guideline for retrieving
data from a database. Nobody can explain to me the reason for the
following.
When retrieving a set of records...
|
by: RayPower |
last post by:
I'm having problem with using DAO recordset to append record into a
table and subsequent code to update other tables in a transaction. The
MDB is Access 2000 with the latest service pack of JET 4....
|
by: ApexData |
last post by:
When I use Dlookup. I am only able to return a single value and
therefore cannot seem to assign a single records (3-field values) to
(3-Variables). I noticed that I can get the 3-field values, but...
|
by: Aussie Rules |
last post by:
Hi,
In all my coding to date, i have been dealing with multiple results in my
dataset, looping through them with
SqlDataAdapterContactProfile.Fill(contact, "Profile")
For Each pRow In...
|
by: jamieda |
last post by:
I have a multiple items form displaying the contents of a table. It has a primary key and the records are ordered by this. I want to be able to manually select a record in the form and then...
|
by: AmateurDBer |
last post by:
Hello, I'm looking for Allen.
I hate to bother you again, but I am now trying to e-mail the single
record from the same form mentioned before (using a macro button) (reference
thread about...
|
by: Greg (codepug |
last post by:
acCmdPrint allows me to print using the Windows Dialog. Since I want
to be able to select the
printer of my choice, this works well. I put his behind a button on a
single form. The problem is,...
|
by: Jerry Maiapu |
last post by:
Hi
Please help.
How can I delete i single record in a datsheet subform from main form using a delete button on the parent form.?
i will be more grateful for your help...
jm
|
by: simulationguy |
last post by:
I have a report that prints all of the records out from a table, usually executed from a reports menu. The user also wants a print button on the data entry form that will print out the exact same...
|
by: eltigreferoz |
last post by:
Hello. I've been trying to create a button on my ACCESS 2007 form that will send a pdf via email of a single record. At the moment (and using code from a previous forum) I have been successful in...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |