Billing Address=Shipping Address check box (1 Viewer)

leafsrock100

Registered User.
Local time
Today, 15:53
Joined
Jul 29, 2010
Messages
17
I have a checkbox on my form that determines whether the shipping address is the same as the billing address.

My VBA code looks like the following:

Private Sub Check_Same_As_Billing_Box_AfterUpdate()
If Check_Same_As_Billing_Box = True Then
ShippingAddress = BillingAddress
ShippingCity = BillingCity
ShippingProvince = BillingProvince
ShippingPostalCode = BillingPostalCode

Else
ShippingAddress = ""
ShippingCity = ""
ShippingProvince = ""
ShippingPostalCode = ""
End If
End Sub

However, when I click the check box on the form, only the shipping address populates with the billing address data but nothing else

What am I doing incorrectly?

Any help would be greatly appreciated,

leafsrock100
 

vbaInet

AWF VIP
Local time
Today, 22:53
Joined
Jan 22, 2010
Messages
26,374
If the Shipping Address is being set then I don't see why the others aren't being set. Are you positive there are values in the others?

If those are all names of controls then try using the Me. qualifier for all of them:
Me.ShippingCity = Me.BillingCity

If they are field names then replace the dot with an exclamation mark, i.e. Me!
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 09:53
Joined
Jan 20, 2009
Messages
12,849
As vbaInet suggested, always fully specify the control or field otherwise Access starts making assumptions and you definitely want to avoid that. I have seen some very odd behaviour when the Me is not included and the control of field name is also used on another open form.

Note that with boolean values you don't need to include the comparison in the If statement.

If Check_Same_As_Billing_Box = True Then

is the same as

If Check_Same_As_Billing_Box Then
 

pcastner1

Registered User.
Local time
Today, 15:53
Joined
Dec 29, 2018
Messages
19
I have a similar issue I have almost the same code, when I enter the address info and check the box the mailing info doesn't fill out.
Private Sub ChkMailingAddressSame_AfterUpdate()
If ChkMailingAddressSame = True Then
Me!Address = Me!MailingAddress
Me!Apt_Lot = Me!MApt_lot
Me!City = Me!MCity
Me!State = Me!MState
Me!Zip = Me!MZip
Else
Me!Address = ""
Me!Apt_Lot = ""
Me!City = ""
Me!State = ""
Me!Zip = ""
End If
End Sub
 

Users who are viewing this thread

Top Bottom