Hi,
Please post in Microsoft Office > Access VBA for better results.
You can put the parameter directly in the query in design view. Enter the following sort of code in the Criteria of the field you want to pass the parameters to:
[Forms]![frmMyForm].[cboMyComboBox]
Then use the button to open the form or report based on this query, and the query will go get the parameter from the combo box itself.
The downside is that this version of the query can only be used for this one button. If you want to pass the parameter to one version fo the query for all uses, then you would do this:
Dim stDocName As String
Dim inComboValue As Integer ' assumes PK is integer is being passed
Dim stLink As String
If IsNull(Me.MyComboBox) or Me.MyComboBox = "" Then
'error handling
Else
inComboValue = Me.MyComboBox
End If
stLink = "[MyPK] = " & inComboValue
stDocName = "frmMyForm" 'or "rptMyReport"
DoCmd.Open... stDocName, , , stLink ' in the WHERE section
HTH
mmcdonal
|