Auto-populate one field from another in same table (1 Viewer)

Nis

Registered User.
Local time
Today, 02:07
Joined
Dec 21, 2012
Messages
23
I have a clients table that has two address fields - the first is the "business address." The second is the "billing address." Is there a way to "default" the billing address to the business address - but allow a change to the billing address in the input form should the two differ?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 02:07
Joined
Feb 28, 2001
Messages
27,148
If you manage this from a form, you could do something like set up the tab order so that you hit the text box for Business Address first, then Billing Address. If you do that, then in the BillingAddress_LostFocus code you could test whether the BillingAddress is empty and the BusinessAddress is not empty, then copy BusinessAddress to BillingAddress.

If you are not up on VBA, this won't be a good solution for you.

I've never actually tried to make a default value that wasn't a constant so any answer I gave would be a guess.
 

Nis

Registered User.
Local time
Today, 02:07
Joined
Dec 21, 2012
Messages
23
I'll give your suggestion a try - and will post back. Thanks!
 

Nis

Registered User.
Local time
Today, 02:07
Joined
Dec 21, 2012
Messages
23
In theory it sounds good, but I'm not very experienced at coding, and not having any luck - so - if anyone has any code suggestions, it would be greatly appreciated.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 02:07
Joined
Feb 28, 2001
Messages
27,148
Use the form wizard to create a LostFocus event for the 2nd text box by opening the form in design mode, then bring up the properties sheet, then click on the Events tab. Find the (probably empty) box for LostFocus and double-click that box so that it says "[Event Procedure]" - and if that box is still selected, the little [...] box is also visible. Click that, and the form will build you a lost-focus routine (which will be empty). Using the names suggested earlier, ...

Code:
IF NZ([BillingAddress],"") = "" THEN [BillingAddress] = NZ([BusinessAddress],"")
 

Nis

Registered User.
Local time
Today, 02:07
Joined
Dec 21, 2012
Messages
23
It works perfectly! Thanks very much!
 

Users who are viewing this thread

Top Bottom