Auto fill a text field based on a checkbox

  • Thread starter Thread starter TinaR
  • Start date Start date
T

TinaR

I'm using Access 2007. I have a form with a tab control and two pages. On
the first page, I have text boxes set up to enter contact information (name,
address, city, state, etc. ). On the second page, I have similar text boxes
set up for a second contact person's info. If the info is the same, I don't
want to have to re-type it on the second page, so I added a checkbox to the
second page asking if the contact info is the same. If the checkbox is
checked, I would like to autopopulate the contact info on the second page
with the same contact info from the first page. Also, if the checkbox is
unchecked, I'd like the text boxes to go back to blank. Can this be done? I
thought I posted this question yesterday but couldn't find my post. Thanks
in advance.

Tina
 
Try this code (untested):

Private Sub chkWhatever_AfterUpdate()
If Me.chkWhatever = True Then
Me.txtAddress2 = Me.txtAddress1
Me.txtCity2 = Me.txtCity1
' etc.
Else
Me.txtAddress2 = ""
Me.txtCity2 = ""
' etc.
End If
End Sub
 
How odd. I thought I posted my reply but it never showed up....
Thanks for your reply. I must be doing something wrong because it didn't
work. I substituted my information into the code you provided. Below is my
code:

Private Sub IsRxContactSameAsPurchasingContact_AfterUpdate()
If Me.IsRxContactSameAsPurchasingContact = True Then
Me.PharmacyContactFirstName = Me.PurchasingManagerFirstName
Else
Me.PharmacyContactFirstName = ""
End If

End Sub

I'm not sure what I'm doing wrong as it seems pretty straightforward. Does
it matter that the first person's contact info (PharmacyContactFirstName) is
on the first page of my tab control and the second person's contact info
(PurchasingManagerFirstName), as well as the checkbox, are on the second page
of the tab control?

Thanks for your help!
Tina
 
Back
Top