Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA newbie, using Access 2000, T 1

Status
Not open for further replies.

shelron

Technical User
Apr 9, 2002
135
US
VBA newbie, using Access 2000,

Trying to tie a cmdbutton to a list box,

the user selects which report they want to run from a list box, then clicks a cmnd button to launch the report, OR they will click another cmd button to launch a pdf.

I keep getting an error when the if is true "runtime error 2497, The action or method requires a Report Name Argument."

I'm at a loss, (I am going to make this a case statement once I figure it out)

Any help would be greatly appreciated. Thanks Ron







Private Sub Command35_Click()

If List31 = 9 Then
DoCmd.OpenReport rptHistorical23, acViewPreview
End If

End Sub
 
Should read:

Private Sub Command35_Click()

If List31 = 9 Then
DoCmd.OpenReport "rptHistorical23", acViewPreview
End If

End Sub

Notice the added quotes....

But.....That dreaded but.....there is a better way to do this....

If the button is simply going to open the currently selected report that is in the list box.....then use:

Private Sub Command35_Click()

' Handle a non-selected click
If IsNull(Me![List31]) Then
MsgBox "Missing Reaport Name"
Exit Sub
End If

DoCmd.OpenReport Me![List31], acViewPreview

End Sub

No you don't need any if statements....it will handle anything in the list box that is selected Please remember to give helpful posts the stars they deserve! This makes the post more visible to others in need! [thumbsup2]

Robert L. Johnson III, A+, Network+, MCP
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
thanks, I just love it when it is easy and simple,

appreciate your help,

Ron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top