Changing the value of one field based on the value of another field

B

barrycrone

I have two fields in my database 'driver' and 'loader'. As the driver
loads his own vehicle 80% of the time I want the value of the 'loader'
field to equal the value in the 'driver' field after the 'driver'
field is updated. I have tried a number of options in AfterUpdate but
without success. Can anyone help.
 
A

Arvin Meyer [MVP]

I have two fields in my database 'driver' and 'loader'. As the driver
loads his own vehicle 80% of the time I want the value of the 'loader'
field to equal the value in the 'driver' field after the 'driver'
field is updated. I have tried a number of options in AfterUpdate but
without success. Can anyone help.

Private Sub Driver_AfterUpdate()
Me.Loader = Me.Driver
End Sub

Where Loader is the name of the loader field textbox and Driver is the name
of the driver field textbox.

Change the names as necessary.
 
M

Marshall Barton

I have two fields in my database 'driver' and 'loader'. As the driver
loads his own vehicle 80% of the time I want the value of the 'loader'
field to equal the value in the 'driver' field after the 'driver'
field is updated. I have tried a number of options in AfterUpdate but
without success.

I think all you need in the Frover text box's AfterUpdate
event procedure is this kind of code:

If IsNull(Me.loader) Then
Me.loader = Me.driver
End If

If you don't want to keep an already filled in loader value,
then remove the If and End If lines.

If you only want to keep an already specified loader when it
was the same as the driver before the replacement driver was
entered, then change the If to:

If Me.driver.OldValue = Me.loader Or IsNull(Me.loader) Then
 

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