Nick,
I am assuming that you only want to populate the full_name field automatically, not allowing the users to actual populate it themselves.
A simple solution could be put within your BeforeUpdate() at the form-level (as opposed to the field-level) in your form which would appear as follows:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Not IsNull(Me.first_name) and Not IsNull(Me.last_name)
Me.full_name = Me.last_name & ", " & Me.first_name
End If
End Sub
This code assumes and will perform the following:
- full_name is a column defined in your underlying table and
is also present on the user form (you will probably want to
lock the field to the user)
- The "Me" keyword refers to the current form
- full_name will only be populated if BOTH the first and last
names are present on the form.
You can also have the full_name field automatically immediately after first or last name is updated by moving this exact code under the AfterUpdate() events of both the first_name and last_name fields on the form. The only difference is that the AfterUpdate() on the fields will show immediate results (provided that values exist in both the first and last name fields) and the BeforeUpdate() on the form itself will only update the full_name field when the user attempts to close the form, go to another existing record, or attempts to add a new record.
Hope this helps.
Warren
:D
|