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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open a report with a specific record showing 1

Status
Not open for further replies.

shaunacol

Programmer
Jan 29, 2001
226
GB
I have a form (frm_DocsList) with a list box (lstQueries) which uses some SQL to pull in a list of some of my reports (the record source is set to SELECT MsysObjects.Name, Mid([Name],5) AS QueryName, Left([Name],4) AS Expr1 FROM MsysObjects WHERE (((Left([Name],4))="Rpts")) ORDER BY MsysObjects.Name;) Also in this form are the clientID, ClientName fields. The idea is that I can choose any one of these reports and open it for the specific client who is shown. But the code I have behind my button does not work. It doesnt seem to like me using criteria with this method. If I take away my strcriteria all the different reports open up beautifully - but not for that specific client. Any help appreciated.


Private Sub cmdPreview_Click()
' opens the report in preview

Dim strCriteria As String

strCriteria = "[ClientID] = & Forms![Frm_docsList]![clientid]"

DoCmd.OpenReport Me.lstQueries, acViewPreview, , strCriteria

End Sub
 
That works! Thank you. I thought I had tried that earlier but must have typed it wonrg. Much appreciated. Now I have to find some code that will close the form after I have opened the report!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top