cmd.openform condition

filo77

Registered User.
Local time
Today, 00:30
Joined
Jul 13, 2004
Messages
16
Hello everybody.

I have a form that has only two combo boxes and once the users selects their choices they get transfered to another form and data from the first form is already in the appropriate fields on the second form. Just a convinience think to advoid repetition.

The problem is that I want to make sure that the users select two choices from both combo boxes before allowing them to continue to the next form.

so in the cmd.openform condition I have:


DoCmd.OpenForm stDocName, , , "[StudentID]=" & Me![Combo0] and "[TestID]=" & Me![Combo2]


now this gives me an error message "type mismatch"

If i check only for one of the combos it works fine

so if my procedure is:

DoCmd.OpenForm stDocName, , , "[StudentID]=" & Me![Combo0]

that is just fine, but I need to check for the two selections.

Now I assume that I have done something extremely silly, but can you please point out what am I missing????

Thanks,

filo
 
DoCmd.OpenForm stDocName, , , "[StudentID]=" & Me![Combo0] & "and [TestID]=" & Me![Combo2]

Try that...
 
DoCmd.OpenForm stDocName, , , "[StudentID]=" & Me![Combo0] & " and [TestID]=" & Me![Combo2]

???
ken
 
ah, yes... what he said...
WAIT!!!

if your values are text it should be like this:

DoCmd.OpenForm stDocName, , , "[StudentID]='" & Me![Combo0] & "' and [TestID]='" & Me![Combo2] & "'"

???
 
Still need help

ReAn,

in fact my fields are text field. I tried what you suggested, but it is not working. It still continues to the second form regardless of selection.

Any ideas.

Thanks for the help.

filo
 
filo,

Code:
If IsNull(Me.Combo0) Or IsNull(Me.Combo2) Then
   MsgBox("Please fill out the combos ..."
Else
   DoCmd.OpenForm stDocName, , , "[StudentID]='" & Me![Combo0] & "' and [TestID]='" & Me![Combo2] & "'"
End If

Wayne
 
Thanks Wayne!

It is working perfectly.


Thank you everyone.

filo
 

Users who are viewing this thread

Back
Top Bottom