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

Getting input for Docmd.openreport ??

Status
Not open for further replies.

Genengineer

Technical User
Feb 5, 2003
6
0
0
US
I tried to set up a form where the user could select Country and Event from combo boxes, and then pass the results to a DoCmd.Openreport.

I tried all sorts of combinations of formatting and kept getting data mismatches or the openreport would not recognize the input, so I gave up and just used the “input” function - that is get access to ask for input for variables it did not recognize as follows.

This works well, but it requires me to put a list of countries on the form so the user types the correct ones in, rather than using the combobox with a “select distinctrow” to show the valid values.

How do I get the combo box entries to transfer to the openreport function? Both Country and Event have text attributes.


Private Sub Runquery_Click()
On Error GoTo Err_Runquery_Click

Dim WClause
Const Rview = "acViewPreview"
Const SView = "SelectRelations"
Const RName = "RegAgreeCountryEvent"
WClause = "[SelectRelations].[Country] = [Enter Country Here]" & _
" AND [SelectRelations].[Event] = [Enter Event Number Here] "

DoCmd.OpenReport _
Reportname:=RName, _
View:=acViewPreview, _
Filtername:=SView, _
WhereCondition:=WClause


' "[Type] = '" & [ProductType] & "'"

Exit_Runquery_Click:
Exit Sub

Err_Runquery_Click:
MsgBox Err.Description
Resume Exit_Runquery_Click

End Sub


Many thanks for any help I can get. I also posted this on forms, as it refers to a form and a report issue......

Ray Shillito

 
Hi,
I wrote two FAQ's on this topic. The first one will use a query, with the criteria being passed to it via the form. You can see this at: faq703-2696 (the report recordsource then becomes the query)

Another technique is to use a "filter" to pass the criteria to the report directly, without the use of a query. You can read about this at: faq703-2657

Be sure to read the other FAQ's. There is some really neat stuff available under each of the various forums. HTH, [pc2]
Randy Smith
California Teachers Association
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top