Hi there,
I am working my way through teaching myself VB an have come quite a long way. Anyway, what I am trying to do is run an ADO SQL query on an access database table that will only return an ID from the SELECT query. However the conditions are that a date field is equal to a specific date and a time field is between 2 times.
BookingDay is a date picked up from a form (and is in the format of dd/mm/yyyy).
BookingTime is also picked up from a form (and is in the format of hh:mm:ss).
BookingEndTime is calculated by adding the designated number of hours (taken from the form) to the BookingTime.
The stuff above is working perfectly well, have run various tests on the values and they are fine.visual basic code:
Dim CheckQuery As String
Dim CheckRecordset As ADODB.Recordset
CheckQuery = "SELECT BookingID FROM Bookings WHERE (BookingDate=#" & BookingDate & "#) " _
& "AND (BookingTime > #" & BookingTime & "# " _
& "AND BookingTime < #" & BookingEndTime & "#)"
Set CheckRecordset = adoConnection.Execute(CheckQuery)
Now the query is executing without an errors, but it is returning 0 rows, an empty recordset. When I go and run a query in the database using the same information, the records show up fine.
Am I missing something obvious here or am I trying to be a bit too complex for my own good?
Oh, the query originally used a BETWEEN statement but I took it out to test the query and so far have not put it back in.
Any help would be greatly appreciated.
Syberius.