Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Type mismatch problem.

Status
Not open for further replies.

BobRodes

Instructor
May 28, 2003
4,215
US
When I execute the following SQL string
Code:
SELECT max([Loaded]) as MaxDate FROM Application_Actives;
in the Access IDE, it works fine. However, when I run it in this VBA context
Code:
Set MyRs = MyDb.OpenRecordset("SELECT max([Loaded]) as MaxDate FROM Application_Actives;")
I get a Type Mismatch error. The [Loaded] field is a date type, and I'm wondering if there's some sort of trick required to convert Access date types to VBA date types. Can someone enlighten me?

TIA

Bob

 
Bob-

I'm not positive, but I think you might need to put # symbols around your date field?

Just a guess.

Hope it helps,

Alex

Ignorance of certain subjects is a great part of wisdom
 
Well, as it turns out, the problem was something completely different. OpenRecordset expects a DAO Recordset, and "Dim MyRs as Recordset" was declaring an ADODB Recordset. Changing it to "Dim MyRs as DAO.Recordset" solved the problem.

Thanks,

Bob
 



Hi,

A date is a date.

Try converting the DATE to LONG
Code:
Set MyRs = MyDb.OpenRecordset("SELECT max(CLng([Loaded])) as MaxDate FROM Application_Actives;")


Skip,

[glasses] [red][/red]
[tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top