Button in form to open filtered report (1 Viewer)

mlozano

Registered User.
Local time
Today, 10:59
Joined
Sep 20, 2009
Messages
18
Hi

I have a form and a report, both based on the same query.

I have placed a button on the form to open the report to show only the current report, with the following code

DoCmd.OpenReport stDocName, acPreview, , "NUMERO = " & Me.NUMERO

Now, I want to change the field to filter from NUMERO to NUMSP. NMSPO is actually the primary key in the original table. Th is primary key is a concatenation of several values.

When I change the code so that the criteria is the NUMSP value, like thi

DoCmd.OpenReport stDocName, acPreview, , "NUMSP = " & Me.NUMSP

it won't work, it'll prompt me for "SP" and another value, than it will show a blank report.

Can anyone help? I am very lost at this point and searching Google does not seem to bring up similar questions elsewhere...

Thanks!
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 10:59
Joined
Aug 30, 2003
Messages
36,135
If this field is text:

DoCmd.OpenReport stDocName, acPreview, , "NUMSP = '" & Me.NUMSP & "'"
 

mlozano

Registered User.
Local time
Today, 10:59
Joined
Sep 20, 2009
Messages
18
Many thanks Paul, it worked perectly!
 

Users who are viewing this thread

Top Bottom