0

Hi Guys,
Just wondering what's wrong with this coding

UN = Form_MAIN!LOGIN_DETAILS.Value
model = Form!COMBO_MODEL.Value
stDocName = "MODEL_SELECTION"

stCOND= "[MODEL_LN]='" & model & "'" And "[TM_NAME]='" & UN & "'"

DoCmd.OpenReport stDocName, acViewPreview, , stCOND

I'm getting a type mismatch error on the line where I specify value to stCOND.
If I run 2 conditions seperately one by one they run fine but when I join them using AND I get an error

Please Help

1
Contributor
1
Reply
2
Views
10 Years
Discussion Span
Last Post by saurabh_kanwar
0

Thanks for your time guys. Problem's solved.

stCOND= "[MODEL_LN]='" & model & "'" And "[TM_NAME]='" & UN & "'"
The problem was in the line above.
"AND" was in VBA, not in text string so the following code worked by including "AND" within the quotes

stCOND = "[MODEL_LN]='" & model & "' AND [TM_NAME]='" & UN & "'"

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.