Do the same thing for the time field criteria as for the date field (surround it with #'s). Also, I am not sure it accepts AM or PM, though I may be wrong about that - I believe it just uses the 24 hour clock times (like military time).
Try the query directly in Access. The problem is the query string, so it is just a matter of working out how the parameters should be formatted. Also, I think there should be apostrophes in addition to the #'s (like this: [apptdate] = '#12/28/01#') around the date/time fields. I know I didn't say that before, but I don't work with Access as my database very often, and it requires some odd things in queries sometimes.
I hate to give up when the only issue is how to build the SQL string. Would you be willing to email the MDB file to me and let me see what I can do about setting up the query string correctly? I am sure I can get it working right if I have access to the database. My email address is seanpatrickmorgan@yahoo.com if you don't mind trying that.
Okay, I received your code and the database today. I am going to send it back to you via email as well, but I wanted to post it here in case anyone else with a similar problem was following this post.
First, I changed the data type for the "Time" field from Text to Date/Time. Next I specified the display format as "Medium Time". The last thing I did to that field was set the input mask to the "Medium Time format" (Mask string: "99:00\ >LL;0;_". Don't put quotes around the mask string when you enter it into Access.
From there all we had to do was properly format the query string. I worked on it in Access and found that you do enclose the date/time criteria in your string with #'s, but do not use the apostrophe (Example: ...WHERE [ApptDate] = #4/9/2002#). You also do the same thing for the time field (Example: ...WHERE [ApptDate]= #4/9/2002# AND Time = #5:00 PM".
Voila! Everything should work like you want it to after that. Give it a try and let me know how it goes.
I recieved that, thanks for the help, but my program still gives me and error message when it get to the connectionstring.open. Obviously I still have issues with my Vb or my programming skills. I chose a simpler approach (I think) of combining the date and time in one field. I can get it to find a similar appointment a send a message for that but if I do not find a match it update the first record in my database and not he one i am displaying in my form. (Maybe I need to start a new thread for this one.
Private Sub apptcheck()
Dim upDateAppt As String
upDateAppt = InputBox("Enter new appointment date and time", " _/_/__, _ am/pm"
Are you using the exact code I sent you? I didn't know the location of your database so I simply refer to "C:\db1.mbd" in my code. Also, make sure you have the correct version of the Jet OLEDB provider available that is specified in the connection string.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.