Trouble with Combo box-from 1/27

G

Gerald Stanley

Try DoCmd.OpenReport without the first comma - the first
parameter should be the report name.

Hope That Helps
Gerald Stanley MCSD
-----Original Message-----
This was from yesterday where I had problems with trying
to click on a selection in a combo box and run a report. I
wanted to run a different report each time a selection was
made. One of the suggestions was to create a command button
and write code behind it for the selection of the combo
box. Here is what I said:
Okay, now this is the code I've put in (2 different ways)
and I get an error with both that says: Compile error:
"Argument not optional"
1st way tried:
Private Sub cmdrunreport_Click()
On Error GoTo Err_cmdrunreport_Click

Dim stDocName As String

Select Case [cboSelectReport]
Case "MA1"
stDocName = "MA1 All"
Case "MA2"
stDocName = "MA2 All"
Case "MA3"
stDocName = "MA3 All"
End Select

DoCmd.OpenReport , stDocName, acViewPreview

Exit_cmdrunreport_Click:
Exit Sub

Err_cmdrunreport_Click:
MsgBox Err.Description
Resume Exit_cmdrunreport_Click

End Sub
-------
2nd way tried:
Private Sub cmdrunreport_Click()
On Error GoTo Err_cmdrunreport_Click

Dim stDocName As String

Select Case [cboSelectReport]
Case "MA1"
stDocName = "MA1 All"
DoCmd.OpenReport , stDocName, acViewPreview

Case "MA2"
stDocName = "MA2 All"
DoCmd.OpenReport , stDocName, acViewPreview

Case "MA3"
stDocName = "MA3 All"
DoCmd.OpenReport , stDocName, acViewPreview

End Select



Exit_cmdrunreport_Click:
Exit Sub

Err_cmdrunreport_Click:
MsgBox Err.Description
Resume Exit_cmdrunreport_Click

End Sub



Print | Copy URL of this post



Expand All Collapse All


Contact Us | Rules of Conduct

.
 

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