Update field with input box result

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to run update and enter date typed in input box bt field in tabquer
Dim messag
message = "enter date
mydate = InputBox(message
CurrentDb.Execute "UPDATE TABQUERY SET TABQUERY.BT = mydate;", dbFailONErro
I get message too few parameters.expected1
Help please
 
mydate = InputBox(message)

CurrentDb.Execute _
"UPDATE TABQUERY SET TABQUERY.BT = mydate;", _
dbFailONError

I get message too few parameters.expected1.

The database engine does not know anything about VBA variable, so you have
to pass the actual value:

strSQL = "UPDATE TabQuery " & _
"SET BT = " & Format(MyDate, "\#yyyy\-mm\-dd\#") & ";"

db.Execute strSQL, dbFailOnError

Look up help on how to pass dates to SQL queries: it is _not_
internationally correct! Also, this will fail badly if the user types in a
non-valid attempt at a date (or cancels out), so you need proper error
trapping.

Hope that helps


Tim F
 
Back
Top