Check box for "Same Address"

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am designing a data base for a car donation charity. It is mostly going
well (I am more that a bit rusty, that access class was a long time ago), but
I have run into some questions.

Here is the situation I have a form that allows data entry into two tables,
the client and car table. Both tables are linked and the form works fine.
But I would like to automate one thing. Right now there is an address stored
in the car table for where the car is located and a address stored in the
client table for where the client is located.

In most cases these are the same addresses, so I would like to have a check
box on the form to copy the street, city, state and zip fields from the
client table to the car table.

I know this can be done with an unbound check box, but I am not sure of the
code to do it. Any help would be greatly aspirated.
 
Jessica,
I don't see the need for a checkbox for this. A button called cmdCopyAddress should do
it.
You didn't describe how the 2 forms are related (Main/Subform or 2 separate forms?)
I'll assume Main/Subform... One Client Many Cars/Locations. (w/ex. Main = frmClient
and Sub = frmCars)
Also if Cars is a continuous subform, the button should be on each record
Basically on the Click event of cmdCopyAddress...

Me.CarAddress = Forms!frmClient!ClientAddress
Me.CarCity = Forms!frmClients!ClientCity
Me.CarState = Forms!frmClients!ClientState
etc.. for all your Car address fields.
 
The organization is as follows:
There is a car table that has all of the info about the cars (including
their location) and has a many to one relation ship with the client table.
They are linked by a field called "client ID", which is an auto number field
in the client table. There are also several other ID fields in the car table
that link it to other tables like one for the make and model.

The form is based on a query that calls all of the fields from client a most
of the fields from car. So the copy I want to happen is all on one form.

Now, for the button....should I use the after update event? One of the
things that the people over me want for this particular form is that all the
data entry in it can be done from the keyboard.

I would greatly appreciate any help with the VB code, I am pretty lost.


Oh and a sub question - can you use a justified form as a sub form??? I
don't like the data sheet view for most of what I am doing. Too many fields
to fit comfee.
 
Jessica,
If Cars are on the same form as Client, then copying can be done directly...
CarAddress = ClientAddress
CarCity = ClientCity
CarState = ClientState

If Cars is a subform of Clients... **which it should be for 2 tables associated One to
Many, and linked by a key field...** you'll have to address the MainForm values to copy a
bit differently...
Me.CarAddress = Forms!frmClient!ClientAddress
Me.CarCity = Forms!frmClients!ClientCity
Me.CarState = Forms!frmClients!ClientState
(Just substitute my form names and field names with your own.)

You wrote...
Now, for the button....should I use the after update event? I previously wrote...
Basically... on the Click event of cmdCopyAddress...
(A button does not have an AfterUpdate event.)

You wrote...
data entry in it can be done from the keyboard.
If you set the Caption of the copy button to...
&Copy Address
then Alt-C from the keyboard would be the same as clicking the button with the mouse...
thereby firing off the "copy" code.

You wrote...
Oh and a sub question - can you use a justified form as a sub form???
Not sure what you mean by "justified subform, but you can build a continous subform and
place the fields where you want. You'll have much more control on size, color, placement,
etc.. with your own continuous form subform.

hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions
 
I am having a naming issue and since you have been so helpful (THANKS!!!), I
figured I would ask here.

I have a table named Make_Model. In it there are the fields VehicleID, Make
and Model. I have Two combo boxes that let you pick the Make and then the
Model. The main table, Car, has a many-to-one relationship with the
VehivleID field from the Make_Model table.

Only the Model combo box is bound (it ties to the VehicleID field in the
main table). There was a query in the Model box that used the make picked in
the Make combo box to just pull the models for that make.

All worked great until I turned the form they were on into Car_Sub and made
it a sub form in the Phone_Email table. Now I am getting the "Enter
Parameter" error because the Model combo box can't find the value in the Make
combo box. How I write the syntax for finding the AOL value?
 
Jessica,
First, from what you described, your table design has a problem.
tblMakeModel should not contain the VehicleID...

Car should not be related to Make and Model... Make and Model should be related to
CAR.
Example data tables and sample values...

tblMake
MakeID Make
12 Ford
17 Dodge
19 Chevrolet

tblModels
MakeID ModelID Model
17 31 Dart
12 16 Mustang
12 22 LTD
19 6 Impala
17 13 Caravan

tblCars
CarID MakeID ModelID
1422 12 22
624 17 31

Car 1422 is a Ford LTD and Car 624 is a Dodge Dart.

Trying to solve "subsequent" problems without good table design can be difficult,
impossible, or at the least... frustrating.
 
--
What do you get when you cross the Godfather with a Philosopher?
Someone that makes you an offer you can not understand.


Al Camp said:
Jessica,
First, from what you described, your table design has a problem.
tblMakeModel should not contain the VehicleID...

Car should not be related to Make and Model... Make and Model should be related to
CAR.
Example data tables and sample values...

tblMake
MakeID Make
12 Ford
17 Dodge
19 Chevrolet

tblModels
MakeID ModelID Model
17 31 Dart
12 16 Mustang
12 22 LTD
19 6 Impala
17 13 Caravan

tblCars
CarID MakeID ModelID
1422 12 22
624 17 31

Car 1422 is a Ford LTD and Car 624 is a Dodge Dart.

Trying to solve "subsequent" problems without good table design can be difficult,
impossible, or at the least... frustrating.
 
Back
Top