Solved

INSERT INTO Date Values

Posted on 2007-11-14
1
1,176 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
ms/acceee link a subform to a control 9 26
Dcount unique 6 24
subform does update on ms/access 2 16
DCount using "OR" 4 19
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

747 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

13 Experts available now in Live!

Get 1:1 Help Now