Auto fill

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form with service address and mailing address fields. How do I
automatically populate the mailing address fields with the service address
data already entered. Most of the time the addresses are the same.
 
BarryC said:
I have a form with service address and mailing address fields. How do
I automatically populate the mailing address fields with the service
address data already entered. Most of the time the addresses are the
same.

You can use code in the AfterUpdate event of the service address
field(s) to set the corresponding mailing address field(s) if it(they)
are currently empty. Along these lines:

'----- start of example code -----
Private Sub ServiceAddress_AfterUpdate()

' Note: this code concatenates the control values with
' a zero-length string and tests the length of the result,
' so as to interpret both a Null value and a zero-length
' string value as "empty".

' Is the service address empty?
If Len(Me!ServiceAddress & vbNullString) <> 0 Then

' No. Is the mailing address empty?

If Len(Me!MailingAddress & vbNullString) = 0 Then

' Yes. Set it equal to the service address.
Me!MailingAddress = Me!ServiceAddress

End If

End If

End Sub
'----- end of example code -----
 
Back
Top