Linking Unbound Field to Bound Field

  • Thread starter Thread starter Jo
  • Start date Start date
J

Jo

What vba script should I use to link an unbound field to a bound field in
Form A so it will update Table B on save.

Here is the situation-I have created unbound fields in Form A to get info
from a query and to carry out calculations. However, I want this information
to update a bound field in Form A on an appropriate event (user tab or after
update) so that I can see the results in Form A and refresh my Table B (bound
field) with the calculated data from the bound field.

Could anyone provide me with a sample of the coding required to do this? I
appreciate your assistance.
 
Hi Jo

If this really is a bound field (i.e. the field you want to update is in the
form's RecordSource and its name is the ControlSource for one of the
controls on your form) then it's easy:

Me![BoundControlName] = Me![UnboundControlName]

The record will be automatically saved when the focus changes to a new
record, or you can save it manually:

DoCmd.RunCommand acCmdSaveRecord

If the field you want to update is in a table which is not part of the
form's RecordSource, then you will need to execute a SQL "Update" statement
to change its value:

strSQL = "Update OtherTable set FieldName=" & NewValue _
& " where " & <selection condition>
CurrentDb.Execute strSQL, dbFailOnError
 
Back
Top