What is the code for updating a field using the contents of a control entered in a form?
Thank you.
What is the code for updating a field using the contents of a control entered in a form?
Thank you.
In SQL:
Update TableNameHere Set FieldNameHere = [Forms]![FormNameHere]![ControlNameHere]
--------------------------------------------
In VBA:
"Update TableNameHere Set FieldNameHere = " & Forms!FormNameHere.ControlNameHere
and if it is text it would need:
"Update TableNameHere Set FieldNameHere = " Chr(34) & Forms!FormNameHere.ControlNameHere & Chr(34)
or for dates
"Update TableNameHere Set FieldNameHere = #" & Forms!FormNameHere.ControlNameHere & "#"
Thanks for the quick response! I'm working in VB. That example didn't work. Trying variations now..
What exactly didn't work when you tried samples that Bob gave?
It gives me a generic syntax error.
Post the EXACT SQL you are attempting to use and also tell us what datatype each of your fields is.
Thanks! I got it with a little trial and error. I see what you were trying to say, but I was in too much of a hurry to slow down and figure it out.