Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying Data

Status
Not open for further replies.

AccessApprentice

Programmer
Apr 14, 2005
14
0
0
US
I have client form that has fields for: address, city, state,zip
and a checkbox to indicate whether or not the client is a minor?

If the checkbox is checked I want to be able to copy the address, city, state and zip from the client table to the parent table as the billing address with fields listed as billingaddress, city, state, zip


Is this possible and if so how can I copy the address from the client table to the parent table or is there an easier solution.

Also if the checkbox is not checked, meaning the client is not a minor I just want to copy the same address info to the same client table but into fields named billingaddress, billingcity, billingstate, billingzip.

The client table is linked to the parent table with a many to one relationship using a parentid.

I'm new to this so sorry if this is a dumb question.
THanks.
 
Hi
There are a few ways to do this. For example, you could run a query in the after update event;
[tt]DoCmd.RunQuery[/tt]
or you could update a recordset;
[tt]Set rs = CurrentDb.OpenRecordset("Select * from tblMain " _ & "Where MyTextKey = '" & Me!MyTextKey & "'"
rs.Edit
rs!BillingAddress = Me!Address
rs.Update[/tt]
if the parent table is open you can copy the fields from one form to another.
[tt]Forms!frmParentfrm!BillingAddress = Me!Address[/tt]

Are any of these what you were thing of?

 
I'm new to this so sorry if this is a dumb question.

No such thing as a dumb question.

You could write two update queries, one for each set of fields. Then use an If clause in the Click event of the Update button to decide which one to run:

Code:
If chkMinor = 1 then
  DoCmd.OpenQuery "MinorUpdate"
Else
  DoCmd.OpenQuery "NormalUpdate"
Endif

No guarantee that this code will run. I know that OpenQuery takes another couple of parameters but they've slipped my mind and I don't have Access here to check.

Geoff Franklin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top