query issue

J

Joseph Atie

I have a query that should add the date entered in a field to a record

The query picks up a barcode from the form and the retired date of the item.
It then adds the retired date of the item to the record in the equipment
register that corresponds to the barcode

here is the code:

DoCmd.RunSQL "UPDATE Equipment SET Equipment.[Date Retired] =" & retired & "
WHERE Equipment.Barcode=" & bcode & ";"

the problem is instead of putting the correct date it puts 30/12/1899
i assume it is something in the sql code as the variable are all correct
according to msgbox
 
K

Kevin Smith

You have missesd the # out of your statement. Currently you are asking for a
number to be returned rather than a date.

DoCmd.RunSQL "UPDATE Equipment SET Equipment.[Date Retired] = #" & retired
& "#
WHERE Equipment.Barcode=" & bcode & ";"
 
J

Joseph Atie

I knew it was something in the formatting of the variable

thanks kevin

Kevin Smith said:
You have missesd the # out of your statement. Currently you are asking for a
number to be returned rather than a date.

DoCmd.RunSQL "UPDATE Equipment SET Equipment.[Date Retired] = #" & retired
& "#
WHERE Equipment.Barcode=" & bcode & ";"
--
Kevin Smith :blush:)


Joseph Atie said:
I have a query that should add the date entered in a field to a record

The query picks up a barcode from the form and the retired date of the item.
It then adds the retired date of the item to the record in the equipment
register that corresponds to the barcode

here is the code:

DoCmd.RunSQL "UPDATE Equipment SET Equipment.[Date Retired] =" & retired & "
WHERE Equipment.Barcode=" & bcode & ";"

the problem is instead of putting the correct date it puts 30/12/1899
i assume it is something in the sql code as the variable are all correct
according to msgbox
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top