|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Ms Access Update Query in VBA
Hi,
I'm trying to run an update query in vba and i'ts not working. I think it's to do with the date field i'm trying to update. here's the query: Dim nextRentDateVal as Date nextRentDateVal = DateAdd("d", 14, dateVal) db.Execute ("UPDATE tbl_Clients SET tbl_Clients.NextRentDate = " & nextRentDateVal & " WHERE tbl_Clients.ClientID=" & Forms![MainMenuF]![ClientID] & "") It does the update but for some strange reason my field is updated to this "12:02:45 AM" any ideas anyone? regards, Aaron. |
|
#2
|
|||
|
|||
|
Your problem has to do with formatting the date properly. You may solve the problem by just putting a # around the date like:
db.Execute ("UPDATE tbl_Clients SET tbl_Clients.NextRentDate = #" & nextRentDateVal & "# WHERE tbl_Clients.ClientID=" & Forms![MainMenuF]![ClientID] & "") which tells Access it's a date, but if that doesn't do it use a Format() function to put the nextRentDateVal into a short date format. |
|
#3
|
|||
|
|||
|
Great!
works perfectly. thankyou very much regards, Aaron. |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > Ms Access Update Query in VBA |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|