Opening a report from a form

G

Guest

Hello,

Im trying to open a report using a print buton and restrict its records to
the value of a text box on a form. Under a print button I have this code

DoCmd.OpenReport "rpt_SelectMemberRequest", acViewPreview, memberID =
Forms!frm_memberOverrideRequest!txtMemberID

Im getting all the records. I only want the records that match the value in
the text box. Does anyone know how to do this?
 
A

Allen Browne

Use the Immediate Window (Ctrl+G) to ask Access what's going on. For
example, type:
? Forms!frm_memberOverrideRequest!txtMemberID
When you press Enter, what do you get?

If you open your table in design view, what type of field is memberID? Is it
Number, or Text? If Text, you need extra quotes:
"memberID = """ & Forms!frm_memberOverrideRequest!txtMemberID & """"

You did include the underscore at the end of the first line?

What happens if you choose Compile from the Debug menu?
 

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