Solved

INSERT INTO Date Values

Posted on 2007-11-14
1
1,177 Views
Last Modified: 2010-05-18
Hitting a wall.  I want to transfer date values from tblInquiry to tblReservations.  Using the code below, I get an incorrect date added to the tblReservations . . . like year 1899.

Dim mySQL As String
    mySQL = "INSERT INTO tblReservation (lngResID, lngGuestID, datArrivalDate, bytNoOfNights, datDepartureDate ) Values(" & Me.lngResID & ", " & Me.lngGuestID & ", " & Me.datArrivalDate & ", " & Me.bytNoOfNights & ", " & Me.datDepartureDate & ")"
    CurrentDb.Execute mySQL

I'm sure I have to do something to the date values, but not sure what.
0
Comment
Question by:copperdave
1 Comment
 
LVL 15

Accepted Solution

by:
jmantha709 earned 250 total points
ID: 20280970
You have to delimit dates using # :

Dim mySQL As String
    mySQL = "INSERT INTO tblReservation (lngResID, lngGuestID, datArrivalDate, bytNoOfNights, datDepartureDate ) Values(" & Me.lngResID & ", " & Me.lngGuestID & ", #" & Me.datArrivalDate & "#, " & Me.bytNoOfNights & ", #" & Me.datDepartureDate & "#)"
    CurrentDb.Execute mySQL
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now