-----Original Message-----
I have a form with 2 combo boxs where i enter, for
example, and ID and a name. Both Combo boxes are unbound.
This is supposed to open a new form based on the criteria i have put on my combo boxs.
Can Access do it for me or i have to go to VBA?
On VBA, how can i do it ?
Thanks for your help
.
The way to do this is by adding a commnd button and
puttig the following code in the On Click event
Dim stLinkCriteria As String
Dim stDocName As String
stLinkCriteria = "[Value1]=" & me.cboComboBox1 & " AND "_
"[Value2] = " & me.cboComboBox2
DoCmd.OpenReport FormName, , , stLinkCriteria
There are a couple of conciderations to think about.
1. Both of the combo boxes need to be populated by the
user. You can check for that using If Then Else statements
before running the code.
2. If the data in the combo box is a string you must use
quotes around the code like this
stLinkCriteria = "[Value1]= '" & me.cboComboBox1 & "'" _
& " AND " & "[Value2] = '" & me.cboComboBox2 & "'"
3. If the data in the combo box is a date you need to
surround the value with #'s like this
stLinkCriteria = "[Value1]= #" & me.cboComboBox1 & "#" _
& " AND " & "[Value2] = #" & me.cboComboBox2 & "#"