-
May 17th, 2008, 05:05 AM
#1
[RESOLVED] Date related problems in VB6 and MS Access
Hi.
Here is the code.
-------------------------------------------------------------------------------------
Private Sub cmdbrt_Click()
bkmark2 = ado_books.Recordset.AbsolutePosition
sqlb = "select * from books where date_of_return < '" & Date & "'"
ado_books.RecordSource = sqlb
ado_books.Refresh
If ado_books.Recordset.RecordCount = 0 Then
MsgBox "No books late"
ado_books.RecordSource = "select * from books"
ado_books.Refresh
ado_books.Recordset.AbsolutePosition = bkmark2
End If
End Sub
------------------------------------------------------------------------------------
The field date_of_return has the value in the format DD-MMM-YY which is similar to what the Date function returns.
Now the problem is that it shows up an error showing "Data Type Mismatch in Criteria Expression".
Any idea how to solve this?
Thanks in advance.
-
May 17th, 2008, 10:12 AM
#2
Re: Date related problems in VB6 and MS Access
MS Access requires you to use the # character on date formats. Like so
Code:
sqlb = "select * from books where date_of_return < #" & Date & "#"
-
May 18th, 2008, 01:12 AM
#3
Re: Date related problems in VB6 and MS Access
Hey. Thanks a ton WillAtwell!! You saved my life! It worked perfectly well.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|