Date Comparison

T

Terry

Date stored in DB as date/time
In VBA, wish to find date that is 2/8/2010
"DateofService" = "2/8/2010" doesn't work.
 
S

Stuart McCall

Terry said:
Date stored in DB as date/time
In VBA, wish to find date that is 2/8/2010
"DateofService" = "2/8/2010" doesn't work.

Try:

"DateofService = #2/8/2010#"

Use hash symbols to indicate that the value is a date.
 
T

Terry

Using the following statement, I received a run-time error 13, type mismatch
on the If "DateofService" = #2/8/2010# Then line .
DateofService is a column defined as a Date/Time data type, whit a Short
Date format.
Do Until rst.EOF
Debug.Print rst("DateofService")
If "DateofService" = #2/8/2010# Then
Debug.Print rst("DateofService")
rst.MoveNext
Else
rst.MoveNext
End If
Loop
Terry
 
T

Terry

I used "DateofService" = #2/8/2010# and received a run-time error '13' type
mismatch on the If "DateofService" = #2/8/2010# line. The suggested
"DateofService = #2/8/2010#" also raised the same error.
Do Until rst.EOF
Debug.Print rst("DateofService")
If "DateofService" = #2/8/2010# Then
Debug.Print rst("DateofService")
rst.MoveNext
Else
rst.MoveNext
End If
Loop

Thanks,
Terry
 
J

Jeanette Cunningham

I haven't read the original part of this thread, but I can see the type
mismatch.
Put rst and brackets around "DateOfService"


If rst( "DateofService") = #2/8/2010#


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top