Link data in fields

M

MasterJack

I want to link data from different fields in one form e.g.

If I have 2 address fields, but they could have the same information, I want
to check a box which makes the data in the second field automatic the same as
the first.
 
B

Brendan Reynolds

in the After Update event procedure of the check box ...

If (Me!NameOfCheckBox) Then
Me!NameOfSecondAddressTextBox = Me!NameOfFirstAddressTextBox
End If

If you want to get a bit more sophisticated, you could check wether there is
anything already in the second text box, and if there is, ask the user do
they really want to overwrite it? This is untested air-code. I think I got
it right, but the possibility of typos/memory lapses on my part can not be
ruled out.

If (Me!NameOfCheckBox) Then
If Len(Trim$(Me!NameOfSecondAddressTextBox & vbNullString)) > 0 Then
If MsgBox ("Do you want to overwrite the second address with the
first one?", vbYesNo Or vbQuestion) = vbYes Then
Me!NameOfSecondAddressTextBox = Me!NameOfFirstAddressTextBox
End If
Else
Me!NameOfSecondAddressTextBox = Me!NameOfFirstAddressTextBox
End If
End If

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Top