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

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 & "'"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.