I'm writing an Excel Macro which works with an existing Access DB. Several of the queries I run will require input from the user as to which users they remove from a table, but seeing as the number will be the same each time I'd rather capture it once at the beginning of the macro and use that variable in my SQL statements. The number is for a quarter number of the year. So it'll either be 1,2,3 or 4 I can capture that from the user ok, but when I try to use the variable in an SQL statement I get the "Data Type Mismatch in Criteria error"
Here is what I'm trying:
Dim Qrtnum As Integer
Qrtnum = Application.InputBox("Enter Quarter to Sample")
sql1 = "DELETE SampledEmailAddressesByQuarter.*, SampledEmailAddressesByQuarter.Quarter FROM SampledEmailAddressesByQuarter WHERE SampledEmailAddressesByQuarter.Quarter = "
appAccess.DoCmd.RunSQL sql1 & Qrtnum
Now in the table in my database the data type is listed as "Binary" and I'm trying to pass an Int variable into my SQL, could this be the problem? Or is the fact I have an Int concatenated with my SQL String?
Any help would be appreciated.
& cstr(Qrtnum)- Mark MooreDELETEwork if you change the datatype of SampledEmailAddressesByQuarter.Quarter to Integer or Long Integer? - HansUp