Problem With Report Filter

G

Guest

When I use this code to limit my report to printing the current record on my
form
I get a sytax error for

missing operator in expression YourPrimaryKey=CurrentValue

This is the code
DoCmd.OpenReport "YourReport", acPreview
Reports![YourReport].Filter = "YourPrimaryKey = " & Me![YourPrimaryKeyControl]
Reports![YourReport].FilterOn = True

Any help would be very useful
 
G

Guest

I should also note that I have the primary key field set us a lookup box so
the text in the box in design view says unbound
 
G

Guest

It would be better to use the WhereCondition argument of the OpenReport
method. For example:

DoCmd.OpenReport "YourReport", acPreview, , "YourPrimaryKey = " &
Me!YourPrimaryKeyControl]

(If it wraps, put it back.)

HTH!

David
 
G

Guest

That brings up the exact same syntax error, could it be beacause I'm using a
lookup box so it shows as unbound
--
Dustin


DBS said:
It would be better to use the WhereCondition argument of the OpenReport
method. For example:

DoCmd.OpenReport "YourReport", acPreview, , "YourPrimaryKey = " &
Me!YourPrimaryKeyControl]

(If it wraps, put it back.)

HTH!

David

Dustin said:
When I use this code to limit my report to printing the current record on my
form
I get a sytax error for

missing operator in expression YourPrimaryKey=CurrentValue

This is the code
DoCmd.OpenReport "YourReport", acPreview
Reports![YourReport].Filter = "YourPrimaryKey = " & Me![YourPrimaryKeyControl]
Reports![YourReport].FilterOn = True

Any help would be very useful
 

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