View Single Post
  #2 (permalink)  
Old February 10th, 2006, 08:58 AM
mmcdonal mmcdonal is offline
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

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
Reply With Quote