
SQL Statement What does it mean?
It might be easier if I try to explain in the whole context of the
statement:
Set rsPORTFOLIO = db.OpenRecordset("select * from
[tblForeignCurrencyTemp] " & "where [BILL_CLIENT] = """ &
txtClient & """", dbOpenDynaset)
The OpenRecordset method expect the first argument to be either a QueryName
or a JET SQL String which is your case. Now in your case, take the Value of
txtClient as "ABC" for example, you want the resultant SQL String to be:
SELECT * FROM [tblForeignCurrencyTemp]
WHERE [BILL_CLIENT] = "ABC"
The problem here is that you need the DoubleQuotes in the resultant SQL
String and you ALSO use the DoubleQuotes in the String concatenation of the
different String components. The way to put a DoubleQuote in a
DoubleQuote-delimited String is to put TWO DoubleQuotes to represent a
single DoubleQuote. Thus, in your case:
"WHERE [BILL_CLIENT] = """
The last DoubleQuote is the String delimiter that goes with the DoubleQuote
before WHERE and the 2 DoubleQuotes after = gives you ONE DoubleQuote in the
resultant String, i.e. the DoubleQuote before ABC.
Also, for you last component of the String concatenation:
""""
The first and last DoubleQuote are the String delimiters that are used in
the concatenation and the 2 DoubleQuotes inside gives you ONE DoubleQuote in
the resultant String, i.e. the DoubleQuote after ABC.
Since JET Database Engine can also use SingleQuotes, you can simplify this
somewhat. Also, you can use the Debug.Print in your code to see the
resultant SQL String which is passed to JET for processing using something
like:
...
Dim strSQL As String
strSQL = "SELECT * FROM [tblForeignCurrencyTemp] " & _
"WHERE [BILL_CLIENT] = """ & txtClient & """"
Debug.Print strSQL
Set rsPORTFOLIO = db.OpenRecordset(strSQL, dbOpenDynaset)
...
and you can actually see the resultant SQL String which is passed to JET.
If you want to use SingleQuotes you can try:
strSQL = "SELECT * FROM [tblForeignCurrencyTemp] " & _
"WHERE [BILL_CLIENT] = '" & txtClient & "'"
(after the = is SingleQuote + DoubleQuote and
the end is DoubleQuote + SingleQuote + DoubleQuote)
but you have to watch out for apostrophes in names.
Alternatively, you can use the Chr$(34) to get the DoubleQuote in the
resultant String like:
strSQL = "SELECT * FROM [tblForeignCurrencyTemp] " & _
"WHERE [BILL_CLIENT] = " & Chr$(34) & txtClient & Chr$(34)
--
HTH
Van T. Dinh
MVP (Access)
Quote:
> Can someone PLEASE tell me what = """ means?
> And what txtClient & """" Means?
> I am trying to figure out what this is actually trying to
> do, what the """ is representing! THANKS for any help!
> Set rsPORTFOLIO = db.OpenRecordset("select * from
> [tblForeignCurrencyTemp] " & "where [BILL_CLIENT] = """ &
> txtClient & """", dbOpenDynaset)
> rsPORTFOLIO.MoveFirst