I have a booking system and it all works fantastically apart from the dates being stored in the form dd/mm/yyyy, except if the date is before the 13th, then it is stored mm/dd/yy.
I want all dates stored as dd/mm/yyyy but i have just read in the help files that any dates in SQL code must be usa format, but not in the query designer.
I have come up with a few solutions but I'm not sure if any are actually doable. I have tried a search but didn't find any answers.
So here's my ideas:
1. Pass the variables to a query in access
2. Insert the data without using sql?
3. Insert the dates number into the table and format it in my forms
If anyones got any other ideas, please let me know, I'm desperate!
Here's my code:
Thanks
Emma
I want all dates stored as dd/mm/yyyy but i have just read in the help files that any dates in SQL code must be usa format, but not in the query designer.
I have come up with a few solutions but I'm not sure if any are actually doable. I have tried a search but didn't find any answers.
So here's my ideas:
1. Pass the variables to a query in access
2. Insert the data without using sql?
3. Insert the dates number into the table and format it in my forms
If anyones got any other ideas, please let me know, I'm desperate!
Here's my code:
Code:
Private Sub add_booking_Click()
Dim dteBookDate As Date
Dim dteLeaveDate As Date
Dim nightnum As Integer
dteBookDate = CDate(Forms("booking2").date1)
dteLeaveDate = CDate(Forms("booking2").date2)
nightnum = Forms("booking2").nights
DoCmd.RunSQL "INSERT INTO booking VALUES (" & Forms("booking2").[room_no] _
& ", #" & Format(dteBookDate, "dd/mm/yyyy") & "#, " & Forms("booking2").[Cust_no] & ", " & False & ", " & nightnum & " );"
dteBookDate = DateAdd("d", 1, dteBookDate)
Do While dteBookDate < dteLeaveDate
DoCmd.RunSQL "INSERT INTO booking VALUES (" & Forms("booking2").[room_no] _
& ", #" & Format(dteBookDate, "dd/mm/yyyy") & "#, " & Forms("booking2").[Cust_no] & ", " & False & "," & 0 & ");"
dteBookDate = DateAdd("d", 1, dteBookDate)
Loop
DoCmd.RunMacro "book_room"
End Sub
Thanks
Emma