Number / text problem.

  • Thread starter Thread starter SpookiePower
  • Start date Start date
S

SpookiePower

I have allways have problems to set all the " ' & signs in the right places in a sql.
Can someone help me to place them right in this sql ?
Me.[combo01] and Me.[combo01] contains the type number

SELECT id FROM tabel01 WHERE month= Me.[combo01] AND year= Me.[combo01]
 
SpookiePower said:
I have allways have problems to set all the " ' & signs in the right places in a sql.
Can someone help me to place them right in this sql ?
Me.[combo01] and Me.[combo01] contains the type number

SELECT id FROM tabel01 WHERE month= Me.[combo01] AND year= Me.[combo01]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dim strSQL As String

strSQL = "SELECT id FROM tabe101 WHERE [month] = " & _
Month(Me!combo01) & _
" AND [year] = " & Year(Me!combo01)

If the value of the Me!combo01 (month) as "January" instead of 1, then
use this:

strSQL = "SELECT id FROM tabe101 " & _
WHERE [month] = '" & Month(Me!combo01) & _
"' AND [year] = " & Year(Me!combo01)

Put the single quote ' around text values.

For full USA format dates use the # delimiter. E.g.:

"... date_column = #2/15/2006# ... "

Or,

"... date_column = #" & Me!txtDateControl & "# ... "


BTW, use more descriptive column names, other than "month" and "year",
'cuz both those words are reserved words in VBA, and, they beg the
questions "What month?" and "What year?". E.g.: closing_month,
fiscal_year, calendar_month, sales_month, calendar_year, etc.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRGOMKoechKqOuFEgEQL8LACbB9wAF9NP0PYtbj5pvSIvDEu31WIAmQFp
VVA97mTAa5Xg/arF1MpwEIvq
=4UaM
-----END PGP SIGNATURE-----
 
MGFoster said:
BTW, use more descriptive column names, other than "month" and "year",
'cuz both those words are reserved words in VBA, and, they beg the
questions "What month?" and "What year?". E.g.: closing_month,
fiscal_year, calendar_month, sales_month, calendar_year, etc.

I know about the reserved words. I did it to make it simple
for those who was going to help me. In my own version, I use
other names.

Thanks a lot. I'll take a look at it later to day :)
 

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

Back
Top