Hi guys, I'm quite new to Access, so be gentle!
I'm currently working with an Access 2000 database (through Access 2003) and I'm trying to make a 'print record' button. I didn't make the database in the first place, so the layout on-screen is hardly as I'd like it, but since its rather a large, business critical database, I'm staying as superficial as I can with the changes.
So, on the main page you enter a reference number which pulls up the appropriate record from the table. What I'm trying to do is print that record, via a report, so that I can format the report in an easier to read manner.
I used wizards to create the report itself and a print-report button and pointed it at my new report. Run on its own however, the report produces pages for the entire database. To combat this, I put a WHERE SQL query (which I'm also very new to) in the OpenReport command in the form where the 'print record' button sits. This looks like this:
DoCmd.OpenReport "Print Report", acNormal, , "[Project Reg Number] = " & Me![Project Reg Number]
[Project Reg Number] is the name of the field in the table that holds the reference number. It is also the name of the text box that holds the reference number when it sits on the form (the form is usually used to edit the record).
The problem with this is, when you click on the button, just before it goes to print, it chucks up an 'Enter Parameter Value' dialog box and asks you to enter the reference number again. Except, that the text within the box (above the text-box you enter data into) is the reference number you need!
So, the SQL query seems to return the reference number, but doesn't put it in the text-box? I'm not sure what's going on, please help!
Thanks
Jamie
PS, that section of code is:
Private Sub print_report_Click()
On Error GoTo Err_print_report_Click
DoCmd.OpenReport "Print Report", acNormal, , "[Project Reg Number] = " & Me![Project Reg Number]
Exit_print_report_Click:
Exit Sub
Err_print_report_Click:
MsgBox Err.Description
Resume Exit_print_report_Click
End Sub