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

Combo boxes

Status
Not open for further replies.

detdu

Technical User
Joined
May 23, 2003
Messages
36
Location
SE
Hi I would really like help with my combo boxes.. I have three of them.. and what i would like to do is after youve chosen a choice in these boxes you can klick a command button and get the report... but the thing is i dont know how... i started off with only two.. and the code ended up like this...

Private Sub runquery_Click()
On Error GoTo Err_runquery_Click

' set up constants and variables

Dim WClause As String
Const Rview = "acViewPreview"
Const SView = "SelectRelations" ' this is a query

' I am using a query to combine results
' from two linked tables

Const RName = "Reportname"
' this is a report
' get the parameters from the combo boxes
WClause = "[SelectRelations].[Country] = '" & Me.CountryCombo & _
"' AND [SelectRelations].[Event] = '" & Me.EventCombo & "'"

' Open the report in preview mode
DoCmd.OpenReport _
Reportname:=RName, _
View:=acViewPreview, _
Filtername:=SView, _
WhereCondition:=WClause

Exit_runquery_Click:
Exit Sub

Err_runquery_Click:
MsgBox Err.Description
Resume Exit_runquery_Click
End Sub


donno if there is anything wrong with it... but it doesnt seem like it... cause when i press the command button i get a box that says enter parameter value.. im going nuts here so i would appreciate if someone could help me.. thx :(
 
Yeah - its because you have put single quotes around the parts in the combo.... shouldn't they be numbers and therefore have no quotes?


Vince
 
I dont know what you mean by numbers... it doesnt matter if I keep the single quotes or del them... it the same... it wont show me the report... or it will.. but its blank...
 
I just did this yesterday with some help and it works great. I created an All Report. Then on a reports page I have 5 combo boxes in which user MUST select a field from each combo box. Won't run if field is left blank. All fields are text. I had a heck of a time with the Quotes and single quotes but finally got it. I need help with trying to create a report where user can ask for two different vendors and two different taxonomy #s. Will be posting later cuz I have tried for a couple days. Any way this is what I used.

Private Sub Preview_Custom_Report_Button_Click()
On Error GoTo Err_Preview_Custom_Report_Button_Click

Dim stDocName As String

stDocName = "rptCombine_Report"

DoCmd.OpenReport "rptCombine_Report", acPreview, , _
"[Vendor Code] = '" & Me.Vendor_Code_Combo & _
"' and [Taxonomy Code] = '" & Me.Taxonomy_Code_Combo & _
"' and [Funding Code] = '" & Me.Funding_Code_Combo & _
"' and [Program Code] = '" & Me.Program_Code_Combo & _
"' and [Reporting Pd] = '" & Me.Reporting_Pd_Combo & "'"

Exit_Preview_Custom_Report_Button_Click:
Exit Sub

Err_Preview_Custom_Report_Button_Click:
MsgBox Err.Description
Resume Exit_Preview_Custom_Report_Button_Click

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top