Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50103

Data Type Mismatch in Criteria Expression

$
0
0
Hello,
I've set up an ADODB.Connection object in a macro to retrieve information from a database. Running a simple query I have tested the code and retrieved sample information - so I know the link to the database works. However, when I try to use a date expression in my query, I get a "Data Type Mismatch in Criteria Expression" error. The query I'm using is as follows:

Code:

statDate = Format(Date, "mm/dd/yyyy")
RCD.Open "SELECT CH.userID, CH.srectype, CH.actvcode, CH.resultcode, count(*) " & _
              "FROM conthist AS CH " & _
              "WHERE CH.ondate = """ & statDate & """" & _
              "GROUP BY CH.userID, CH.srectype, CH.actvcode, CH.resultcode", CNN, 3

I'm fairly certain that it's just the syntax of the date expression but can't figure out the correct syntax. I'm referring to a database in Frontrange Goldmine which uses "Dbase IV". When I run the same query in Goldmine's SQL tool, the format for query is:

Code:

SELECT CH.userID, CH.srectype, CH.actvcode, CH.resultcode, count(*)
FROM conthist AS CH
WHERE CH.ondate = '10/11/2012'
GROUP BY CH.userID, CH.srectype, CH.actvcode, CH.resultcode

Any help with the correct syntax would be much appreciated.

Thanks
Williams485

Viewing all articles
Browse latest Browse all 50103

Trending Articles