Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

INSERT INTO Date Values

Posted on 2007-11-14
1
Medium Priority
?
1,196 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 1000 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 learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

885 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