I have created the database in Microsoft Access
with this query
SELECT * from booking WHERE BOOK_DATE = DATE() order by book_time*
it returns 3 records which has BOOK_DATE = today date
but…
when i tried to place it in the Visual Basic with Data Control and DBGrid, i enter the query in the RecordSource property, but the data didnt come out when i execute the program
what did i miss about DATE()
doesn’t it support in vb, shall i replace it with something else?
WHERE BOOK_DATE = DATE()
VB6 knows about DATE() as I have used it recently. I suspect that the data control can’t handle a built in function such as DATE() in the RecordSource. Can you change the RecordSource in the code, such as in the forms Open event or whatever approriate, to put in the date? Something like:
Note that # are date delimiters similar to how ‘ or ” (quotes or double quotes) are delimiters. Assuming that the data control works the same as I’m used to in Access. Also note though that you sometimes don’t need those but you should be aware of them.
Also if any systems are running anything but mm/dd/yy format, or if there’s even the slightest possibility this could happen then you should be ware of the following.
SQL statements require that the dates be either completely unambiguous or in mm/dd/yy, or mm/dd/yyyy format. Otherwise Access/Jet will do it’s best to interpret the date with unknown results depending on the specific date it is working with. You can’t assume that the system you are working on is using those date formats. Thus you should use the logic at the following web page.
Return Dates in US #mm/dd/yyyy# format
http://www.mvps.org/access/datetime/date0005.htm