Linking Unbound Field to Bound Field

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.
 
G

Graham Mandeno

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top