I need help in using the proper double quotation in a defined text string.
This code is based in a previous response on limiting content of one combo
box from what's selected in a another combo box. I already made one combo box
work on a simple query, but here I got some complexity since I need to add an
expression in my limited knowledge on using single and double quotations is
not helping my find the correct way to write it.
Dim strSQL1 as String
strSQL1 = "SELECT [Unit-State].Unit, [Unit-State].State FROM [Unit-State]"
strSQL1 = strSQL1 & " WHERE ((([Unit-State].State)=IIf(" & Me![GasTypeCode]
strSQL1 = strSQL1 & "=Vac Or " & Me![Combo1]
strSQL1 = strSQL1 & "=PVac,PV,P))) ORDER BY [Unit-State].Unit;"
Me!Combo1.RowSource = strSQL1
I want to limit that whenever Me!Combo1 is "Vac" or "PVac", my query
criteria is filtered by "PV", otherwise my query criteria should be filtered
by "P"
Thanks.
Ken Snell (MVP) - 23 May 2007 04:18 GMT
Dim strSQL1 as String, strIf As String
If Me![GasTypeCode] = "Vac" Or Me![GasTypeCode] = "PVac" Then
strIf = "PV"
Else
strIf = "P"
End If
strSQL1 = "SELECT [Unit-State].Unit, [Unit-State].State FROM [Unit-State]"
strSQL1 = strSQL1 & " WHERE [Unit-State].State='" & strIf & "'"
strSQL1 = strSQL1 & " ORDER BY [Unit-State].Unit;"
Me!Combo1.RowSource = strSQL1

Signature
Ken Snell
<MS ACCESS MVP>
>I need help in using the proper double quotation in a defined text string.
> This code is based in a previous response on limiting content of one combo
[quoted text clipped - 21 lines]
>
> Thanks.
Martin - 23 May 2007 17:35 GMT
Brilliant!!
> Dim strSQL1 as String, strIf As String
> If Me![GasTypeCode] = "Vac" Or Me![GasTypeCode] = "PVac" Then
[quoted text clipped - 32 lines]
> >
> > Thanks.