J
Jeff_NC
Guest
I've searched these forums and haven't found a similar problem yet. It's probably something simple and stupid that i'm doing wrong.
I'm creating a video rental system in access and wish to insert a due date into one of my tables. For example I have a form which has three values account_number, product_id, and due_date.
I have a button that executes my procedure that then calculates the due date by using Date + 3 and sends it back to the form and then executes my SQL statement to insert those three values into my table. The date shows up correctly back in the form but it inserts some crazy value into the table and I can't figure out why.
Here is the procedure:
Private Sub check_out_item_Click()
Dim dueDate As Date
Dim pID, acctNum As Variant
dueDate = Date + 3
due_date.Value = dueDate
pID = product_id.Value
acctNum = account_number.Value
DoCmd.RunSQL "INSERT INTO Items_Checked_Out (account_number, product_id, due_date) VALUES (" & acctNum & ", " & pID & "," & dueDate & ")"
End Sub
Now for instance when the date gets calculated as 5/2/2002 it shows up in the table as 12/30/1899 and even weirder is that when I click on that field in the table it switches to a time value.
The due_date field in the table is set to Date/Time type using Short Date.
Any ideas what is going on?
I'm creating a video rental system in access and wish to insert a due date into one of my tables. For example I have a form which has three values account_number, product_id, and due_date.
I have a button that executes my procedure that then calculates the due date by using Date + 3 and sends it back to the form and then executes my SQL statement to insert those three values into my table. The date shows up correctly back in the form but it inserts some crazy value into the table and I can't figure out why.
Here is the procedure:
Private Sub check_out_item_Click()
Dim dueDate As Date
Dim pID, acctNum As Variant
dueDate = Date + 3
due_date.Value = dueDate
pID = product_id.Value
acctNum = account_number.Value
DoCmd.RunSQL "INSERT INTO Items_Checked_Out (account_number, product_id, due_date) VALUES (" & acctNum & ", " & pID & "," & dueDate & ")"
End Sub
Now for instance when the date gets calculated as 5/2/2002 it shows up in the table as 12/30/1899 and even weirder is that when I click on that field in the table it switches to a time value.
The due_date field in the table is set to Date/Time type using Short Date.
Any ideas what is going on?