Update table field from a unbound form

R

Rony

Hi
I am unable to update a field from input form (UNBOUND)to a table.

Field in form [re]-unbound

Table name = MASTER
Field Name = ref

I need to to update the input value of the form to the table ref field


I have palce the following code in the form-field [re] After Update Event
DoCmd.RunSQL "UPDATE[Master] Set[REF] ='" & Me!RE.Value & " '"

System indicates - 0 records updated

Please help

Thanks
 
D

Douglas J. Steele

If that's an actual cut-and-paste of your code, try putting a space after
the keyword UPDATE:

DoCmd.RunSQL "UPDATE [Master] Set[REF] ='" & Me!RE.Value & "'"

I always prefer to use the Execute method of the DAO Database object myself,
as it'll let you trap any errors that may have occurred running your
statement.

CurrentDB.Execute "UPDATE [Master] Set[REF] ='" & Me!RE.Value & "'",
dbFailOnError

(It also avoids the popup message about "You are about to update x
records".)
 
O

Ofer

To add to Douglas, just incase the field type is number use this

DoCmd.RunSQL "UPDATE [Master] Set [REF] =" & Me!RE.Value
 
Top