Please Help -- "Same as Billing Address" Checkbox --- is this possible!?!?!?

BrentG

Registered User.
Local time
Today, 15:50
Joined
Jun 29, 2006
Messages
20
 
In the after update event of the checkbox, test the value of it with an If/Then. If true, copy the values from billing to shipping textboxes and lock each control. If not, unlock each control (and I'd probably blank out the shipping controls).
 
Very New to VB.. example code somwhere?

pbaldy,

Thanks a million for your response. I understand what you wrote, and I know where and how to input the code... But i dont know the code!!

Where could I find examples for the specific coding?? If you have similar code somwhere I'm sure I could mess with it and make it work!! (I'm starting to be able to read it pretty well!)

Thanks again my friend
 
Which part? The copying is:

Me.ShippingAddress = Me.BillingAddress

Where ShippingAddress and BillingAddress are the names of the controls you want to copy to/from. The locking is:

Me.ShippingAddress.Locked = True (or False to unlock)
 
I'll try to make that work

I'll try to make that work. Theres plenty of sources here to use the structure of an IF statement in VB... I'll let you know tomorow if I run into any problems. (I probably will so please check)... Id like to try to write this on my own!

THanks man.
 
Tried a few things... not working..

Hey Guys,

OK this is what Ive done so far:

PHP:
Private Sub AddCheck_Click()

Dim Locked As Boolean
   If AddCheck.Value = vbChecked Then
      Me.PropertyAddress = Me.PA
      Me.City = Me.Cty
      Me.PostalCode = Me.PC

      Locked = True
   Else
      Locked = False
   End If
   Me.PropertyAddress.Locked = Locked
   Me. City.Locked = Locked
   Me.PostaCode = Locked

End Sub

and in the BeforeUpdate section of the form itself i put:

PHP:
Private Sub Form_BeforeUpdate(Cancel As Integer)

[Customers]![StreetAddress] = Me.SA
[Customers]![City] = Me.Cty
[Customers]![PostalCode] = Me.PC

End Sub


I'm really new at this... so maybe its somthing obvious like the declarations are in the wrong spot or somthing (though Ive tried putting it in a few places) . The problem is that the StreetAddress City and PostalCode of the Customer are NOT in this form. I need that data COPIED from their source in the Customers table and pasted into my PropertyAddress (etc) fields in this form, which is the Order form...

I'm Stuck!!!!

Thanks Guys
 
If the fields are not in the form's source, you'll need to go get the values. The 2 common methods are either a DLookup or opening a recordset. The recordset is more efficient but the Dlookup may be easier to understand. It would look something like:

Code:
Me.StreetAddress = DLookup("StreetAddressField", "CustomerTableName", "CustomerID = " & Me.CustomerID)

More info in VBA Help for the DLookup plus here:

http://www.mvps.org/access/general/gen0018.htm
 
Almost there

Hey Paul,

Thanks a million man, works flawlessly

This is what I ended up with for anyone that might need somthing like this:

PHP:
Private Sub Check44_Click()
On Error GoTo Err_Check44
   If Check44.Value = True Then
      Me.PropertyAddress = DLookup("StreetAddress", "Customers", "CustomerID = " & Me.CustomerID)
      Me.City = DLookup("City", "Customers", "CustomerID = " & Me.CustomerID)
      Me.PostalCode = DLookup("PostalCode", "Customers", "CustomerID = " & Me.CustomerID)

      Locked = True
   Else
      Me.PropertyAddress = ""
      Me.City = ""
      Me.PostalCode = ""
      
      Locked = False
   End If
   Me.PropertyAddress.Locked = Locked
   Me.City.Locked = Locked
   Me.PostalCode.Locked = Locked
   Exit Sub

Err_Check44:
    
    MsgBox "Must Enter Company Name", vbOKOnly, "Enter Company"
    Check44.Value = False
    
End Sub
 
Last edited:

Users who are viewing this thread

Back
Top Bottom