0

I need some help with my query I am trying to insert to a table see above code:

CurrentDb.Execute ("INSERT INTO tblWarehouseItem ( whiwrhID, whiItemName, whivatName," whiVatRate, whiimtID, whiQty, whiPrice, whisupID, whiDateIn, whiExpiryDate,whiwhiID ) " & _
                                   " Values (" & rs!WID & "," & Chr(34) & rs!N & Chr(34) & "," & Chr(34) & rs!VN & Chr(34) & "," & rs!VR & "," & rs!IID & "," & intQtyForm & "," & rs!PR & "," & rs!SID & "," & CDate(rs!DIN) & "," & CDate(rs!EXD) & "," & rs!ID & ")")

In my table the CDate(rs!EXD) and CDate(rs!DIN) are stored as time.

When I compile my query in the immediate window I get Dates.

INSERT INTO tblWarehouseItem ( whiwrhID, whiItemName, whivatName, whiVatRate, whiimtID, whiQty, whiPrice, whisupID, whiDateIn, whiExpiryDate,whiwhiID )  Values (2,"ITEM10","A",19,14,4,20,10,21/07/14,26/05/14,60)

How can I make my query to insert the date in the table?

thanks in advance

1
  • is there a particular reason you are using a recordset to populate the query instead of doing a INSERT INTO ... SELECT which would sidestep this entire problem? Or, you can Format(rs!DIN,'dd/mm/yyyy HH:MM') or, TimeValue() Commented Jul 23, 2014 at 10:58

1 Answer 1

2

If you run that 21/07/14 is passed to Access and interpreted as an integer resulting from 12 divide by 7 divide by 14 which when converted to a date is just a time.

Delimit dates with #:

.. ",#" & CDate(rs!DIN) & "#," ..
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.