Sorry, I don't use spaces in my fields and missing putting [ ] around Date
Taken.
Dim MonthNum as Long
Dim DTMonth as Long
Dim strSQL as String
DTMonth = DatePart("m", [Date Taken])
MonthNum = DatePart("m", Date) - 1
strSQL = "Delete * from tblInventoryTaken" _
& "where DTMonth = " & MonthNum
DoCmd.RunSQL strSQL
"DebbieG" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
| Dim MonthNum as Long
| Dim DTMonth as Long
| Dim strSQL as String
| DTMonth = DatePart("m", Date Taken)
| MonthNum = DatePart("m", Date) - 1
| strSQL = "Delete * from tblInventoryTaken" _
| & "where DTMonth = " & MonthNum
| DoCmd.RunSQL strSQL
|
|
| "matt donker via AccessMonster.com" <(E-Mail Removed)> wrote in message
| news:(E-Mail Removed)...
|| Allright i am a semi new access database developer and i am tearing my hair
|| out at this one.
||
|| I want to run some SQL from vb using and in the where statement make it
|| compart to a variable. This is what i have (Well there is a ton more code
|| but this is what is significant)
||
|| Dim MonthNum$
|| Dim strSQL
|| MonthNum$ = DatePart("m", Date) - 1
|| strSQL = "DELETE * FROM [tblInventoryTaken] WHERE DatePart(m, Date Taken) =
|| MonthNum$"
||
|| Now i have changed so much around to try to get this thing to work and
|| regardless of what i do it always comes up with an error. One problem i am
|| having is that the date part statement you cannot use double quotes around
|| the m or you get and expected end of line error. Anyway if any of you can
|| help out i would sure appreciate it thanks.
||
|| Matt
||
|| --
|| Message posted via
http://www.accessmonster.com
|
|