Multiple where condition (numeric + string)

Capitala

Member
Local time
Today, 23:09
Joined
Oct 21, 2021
Messages
91
Sorry for disturb!
I need to open a report from a current form with two where conditions; first is numeric and the second is string.
DoCmd.OpenReport ("abc"), acViewPreview , , (where condition)
Thanks in advance
 
It is easiest to build complex strings in variables so you can have an easy way to print them to the debug windo if you have trouble.
Code:
Dim strWhere as String

strWhere = "fld1 = '" & Me.textfield & "' AND fld2 =" & Me.numericfield

This assumes that the text field does not contain embed single quotes. If the text field is a name then the embedding of the double quotes gets more complicated. In all my apps I create a constant named QUOTE
Code:
Public Const QUOTE = """"
Then the statement would be:
Code:
strWhere = "fld1 = " & QUOTE & Me.textfield & QUOTE & " AND fld2 =" & Me.numericfield
It works, thanks alot
 

Users who are viewing this thread

Back
Top Bottom