If True then copy and paste, If False do nothing

G

Guest

I have a form Clients based on a table Prospects and I have fields Client
address, Client City, Client State, Client Zip on my form and in my table. I
want to put a check box for Billing address is the same as Client Address and
if the box is checked yes I want the data form this client copied from the
above fields to Client Billing address, Client Billing City, Client Billing
State, & Client Billing Zip. I have no clue how to do this can someone
Helllllpppp.


thanks
Gary
 
C

Carl Rapson

In the BeforeInsert event of the form, check the value of the checkbox and
if it's True, copy the values from the Client address fields to the Billing
address fields.

Carl Rapson
 
G

Guest

I should have let you know I am not a complete novice but pretty close. I
don't see a before insert in the event property only a before update and I
don't get how to tell access to if it's true copy the values and paste.
Thanks for the quick response but I need more step by step and details.

Thanks,

Gary
 
C

Carl Rapson

On the Events tab of the Properties window, Before Insert should be the
second item (just below On Current). Make sure you are looking at the
Properties window for the form, not a control on the form.

In the BeforeInsert event, you would do something like this:

If chkCheckBox = True Then
Me.Client_Billing_Address = Me.Client_Address
... 'Repeat for other fields
End If

Of course, you'll need to use your actual control or field names instead of
the ones I've made up. And you may want to put the same code in the
BeforeUpdate event, if the user can check the box when updating a records as
well as when creating a record.

Carl Rapson
 
G

Guest

Private Sub Form_BeforeInsert(Cancel As Integer)
If chkbill_same_address = True Then
Me.CLIENT.ADDRESS_1 = Me.CLIENT.CLIENT_BILL_ADDRESS_1
End If
End Sub
This is what I have in my property box for before insert. Nothing happens
except I get an error message saying compile error. I know it's me but I
have tried brackets and dots and everything else I can think of to get a
proper response and I keep getting some kind of error message.

Thanks,

Gary
 
C

Carl Rapson

The names I used were examples, not necessarily the names you will use. You
should use the names of the actual controls on your form for each of those
fields. To see the actual control name, click on the control and look at the
Properties window.

If the names you used in your original question were the actual control
names, then you would use:

Me.Client_Billing_Address = Me.Client_Address
Me.Client_Billing_City = Me.Client_City
Me.Client_Billing_State = Me.Client_State
Me.Client_Billing_Zip = Me.Client_Zip

Carl Rapson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top