Problem With Report Filter

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
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
 
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
 
Back
Top