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

DoCmd to open report where Relationship is base on Input box

Status
Not open for further replies.

nmapeso

Technical User
Aug 26, 2005
28
US
Hello eveyrone I have a report name rptDivision and one of the fields is Relationship. I'm trying to figure out how to open the report with criteria for field Relationship = to Life, Auto or Finance by using InputBox where user enter life and report shows the criteria on life or auto, Finace.
Somehow the stWrhere doesn't work.


Private Sub Report_by_Division_Click()
On Error GoTo Err_Report_by_Division_Click
Dim stWhere As String
Dim stDocName As String
Dim Message, Title, MyValue
Message = "Auto, Life"
Title = "Report By Division"
MyValue = InputBox(Message, Title)
stDocName = "rtpDivision"
stWhere = "[Relationship] = " & MyValue
DoCmd.OpenReport stDocName, acPreview, , stWhere

Exit_Report_by_Division_Click:
Exit Sub

Err_Report_by_Division_Click:
MsgBox Err.Description
Resume Exit_Report_by_Division_Click

End Sub
 
Change your code to include quotes around the string:

stWhere = "[Relationship] = " & Chr(34) & MyValue & Chr(34)

"Have a great day today and a better day tomorrow!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top