Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

INSERT INTO Date Values

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

861 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