J
JB
I have a complex query with multiple rows and columns of criteria that
I am modifying for a new issue for my client. Originally I had a
Network field in the query that set the criteria string as:
In("choice1","choice2","choice3","choice4","choice5", "choice6")
where the choices were hard coded. This has always worked fine.
Now the choices need to be dynamic based on the selection in the form.
I do not want to dynamically write the whole SQL string if I can help
it, since it would be a long complex mess. I just need to fix this one
field's criteria setting. Based on a check box on the form, the Network
critieria now needs to be:
In("choice1","choice2","choice3","choice4","choice5", "choice6")
or it may need to be:
In("choice1","choice2","choice3","choice4","choice7")
I am trying to build the string in a text box on the form and then have
the query refer to the form field. No matter what combinations I try
with double or single quotes, the query returns no records. If I
manually test the query, it works fine and there are many records.
My query criteria for the field looks like:
"IN (" & [Forms]![frmWeeklyBroadcastSchedule]![txtNetworks] & " )"
My code on the form looks like:
If Me.chkOldNetwork Then
Me.txtNetworks =
"""""abc"""",""""cbs"""",""""nbc"""",""""fox"""",""""wb"""",""""upn"""""
Else
Me.txtNetworks =
"""""abc"""",""""cbs"""",""""nbc"""",""""fox"""",""""cw"""""
End If
If I use Debug.Print to test the result, I get:
IN (""abc"",""cbs"",""nbc"",""fox"",""cw"" )
I just want a version with a single quote for the IN statement but the
compiler chokes on other combinations of quotes in the IF statement. I
have tried using OR instead of IN where appropriate but I get the same
problem.
Does anyone have an idea?
I am modifying for a new issue for my client. Originally I had a
Network field in the query that set the criteria string as:
In("choice1","choice2","choice3","choice4","choice5", "choice6")
where the choices were hard coded. This has always worked fine.
Now the choices need to be dynamic based on the selection in the form.
I do not want to dynamically write the whole SQL string if I can help
it, since it would be a long complex mess. I just need to fix this one
field's criteria setting. Based on a check box on the form, the Network
critieria now needs to be:
In("choice1","choice2","choice3","choice4","choice5", "choice6")
or it may need to be:
In("choice1","choice2","choice3","choice4","choice7")
I am trying to build the string in a text box on the form and then have
the query refer to the form field. No matter what combinations I try
with double or single quotes, the query returns no records. If I
manually test the query, it works fine and there are many records.
My query criteria for the field looks like:
"IN (" & [Forms]![frmWeeklyBroadcastSchedule]![txtNetworks] & " )"
My code on the form looks like:
If Me.chkOldNetwork Then
Me.txtNetworks =
"""""abc"""",""""cbs"""",""""nbc"""",""""fox"""",""""wb"""",""""upn"""""
Else
Me.txtNetworks =
"""""abc"""",""""cbs"""",""""nbc"""",""""fox"""",""""cw"""""
End If
If I use Debug.Print to test the result, I get:
IN (""abc"",""cbs"",""nbc"",""fox"",""cw"" )
I just want a version with a single quote for the IN statement but the
compiler chokes on other combinations of quotes in the IF statement. I
have tried using OR instead of IN where appropriate but I get the same
problem.
Does anyone have an idea?