View Full Version : button on form to run report from query


smp48
04-26-2004, 10:10 AM
I have an Access 97 database that collects data and runs a report used as a customer quote by Sales. I created a report which gets its data from a query which asks user to enter quote number (unique number used as primary key). When I select the report on Report Tab and press Print Preview button, query runs and displays report on screen.

I tried to put a command button on the form so user does not have to close form and go to Report Tab. Everything looks OK but query does not run when I click on the button. :confused:

I used wizards to create report and button on form.

I am new here and I mostly use wizards as I am self taught in Access 97 and have not yet learned about code so please be as simple as you can.

Any help is very much appreciated. Thanks in advance.

Rich
04-26-2004, 11:20 AM
Post the Code behind the button

smp48
04-27-2004, 07:04 AM
Post the Code behind the button

I created the button with the wizard and selected the report "Email Quote"
(this report on Report tab runs the query which asks for quote # and then prints report using data from that quote #). Pressing the button does not run query but instead displays following error for On Click event "ambiguous name detected: Fax_Quote_1_Click". (I also have similar report called "Fax Quote").

Here is the code:

Private Sub Email_Quote_Click()
On Error GoTo Err_Email_Quote_Click

Dim stDocName As String

stDocName = "Email Quote"
DoCmd.OpenReport stDocName, acPreview

Exit_Email_Quote_Click:
Exit Sub

Err_Email_Quote_Click:
MsgBox Err.Description
Resume Exit_Email_Quote_Click

End Sub