Recordset as Variable in SQL Statement

D

DoveArrow

Here's my problem: I want to use text from a field in a Recordset that
I've created as a variable in a SQL statement. However, the text I'm
referencing has a period in it. As a result, instead of appearing as
text ('BS.BUAC'), the computer thinks it's referencing a field ([BS].
[BUAC]). I've tried putting quotation marks around it, I've tried
putting the Chr(34) ASCII codes around it, I've tried using Like
statements, In statements, and equal statements, but the computer not
only ignores them, it removes them from the final SQL statement.

I'm not that familiar with trying to translate VBA into SQL and/or
back again, so I find myself stuck with this and with no idea how to
proceed. If anyone can help me with this issue, I would really
appreciate it. Oh, and if you're interested, here's the portion of the
SQL statement that I'm trying to run. Note: [rs]![Program] is the
field in my Recordset that I'm trying to reference.

WHERE (((jtblMajorSpecialization.CatalogYear)=[Forms]!
[frmProgramChange]![CatalogYear]) AND
((jtblMajorSpecialization.Program) " & Chr(34) & [rs]![Program] &
Chr(34) & ")
 
D

DoveArrow

Here's my problem: I want to use text from a field in a Recordset that
I've created as a variable in a SQL statement. However, the text I'm
referencing has a period in it. As a result, instead of appearing as
text ('BS.BUAC'), the computer thinks it's referencing a field ([BS].
[BUAC]). I've tried putting quotation marks around it, I've tried
putting the Chr(34) ASCII codes around it, I've tried using Like
statements, In statements, and equal statements, but the computer not
only ignores them, it removes them from the final SQL statement.

I'm not that familiar with trying to translate VBA into SQL and/or
back again, so I find myself stuck with this and with no idea how to
proceed. If anyone can help me with this issue, I would really
appreciate it. Oh, and if you're interested, here's the portion of the
SQL statement that I'm trying to run. Note: [rs]![Program] is the
field in my Recordset that I'm trying to reference.

WHERE (((jtblMajorSpecialization.CatalogYear)=[Forms]!
[frmProgramChange]![CatalogYear]) AND
((jtblMajorSpecialization.Program) " & Chr(34) & [rs]![Program] &
Chr(34) & ")

Nevermind. I decided that this wasn't the way to go and went a
different route.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top