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-----