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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listbox SQL problem 1

Status
Not open for further replies.

BradB

MIS
Jun 21, 2001
237
0
0
US
VB6 SP5
Access 2002

Listbox = lstLogDates
Field = tblLog.Date (date/time) format

The listbox will have a list of dates. When I click on the dates in the listbox, I want it to return data from the database to a listview. Anyway, I'm running into problems when I query the database. When I click on the Dates in the listbox, I get the following error.

Error Message
Run-time error '3464'
Data type mismatch in criteria expression

The folloing code is where the problem lies.

Doesn't work
"WHERE tblLog.Date='" & lstLogDates.Text & "'", dbOpenSnapshot)

OR

Doesn't work
"WHERE tblLog.Date='" & CDate(lstLogDates.Text) & "'", dbOpenSnapshot)
 
Instead of:
"WHERE tblLog.Date='" & lstLogDates.Text & "'", dbOpenSnapshot)

Use:
"WHERE tblLog.Date=#" & lstLogDates.Text & "#", dbOpenSnapshot)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top