Open Report/Query Filter

G

Guest

The following query works on my form and selects the record I want to print
which
searches on Last Name and then one of several unique PresID values selected
in the subform. Txtlink is a calculated value on a main form textbox to
supply the PresID value selected on the subform.

SELECT Table1.*, Table2.*
FROM Table1 INNER JOIN Table2 ON Table1.LastName=Table2.LastName
WHERE (((Table2.PresID)=Forms![PfForm]!txtLink));

However, when I use a macro to open a report based on this form and filter
it by using this query,(by typing in the filter name in the action argument)
it doesn't work. The error message is "Enter Parameter Value:
Table2.PresID."

I don't understand why the Open Report macro won't accept the query while it
will with the form. Any suggestions from anyone would be appreciated.

Jay
 
D

Duane Hookom

You should get used to coding for stuff like this. Consider creating a
button using the wizard that opens the report. Then add code like:

Dim strWhere as String
dim stDocument as String
stDocument = "rptUnNamedReport"
strWhere = "PresID = " & Me.txtLink
DoCmd.OpenReport stDocument, acPreview, , strWhere

If you don't want to use code, try change the "Table2.PresID" to just
"PresID". This assumes you only have PresID in one table.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top