By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,490 Members | 1,489 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,490 IT Pros & Developers. It's quick & easy.

How to add data from one form to another

P: n/a
hi everybody-

what is the best way to add data from one form to another?

i have 2 tables: person and contract. here are some of the fields.

table: person

personid (autonumber and primary key)
ss#
firstname
lastname
address1
adress2
city
state
zip
phone

table: contract
contractid (autonumber and primary key)
contracttype
startdate
enddate
employeeid
personid (foreign key to person table)

there is a 1 to many relationship between person and contract.

a person can have 1 or more contracts.
a contract can have 1 and only 1 person.
i have a question about 2 of my forms. my first form, frmPerson, is
based on the person table. it is a simple form to enter information
about a person. i used personid as the primary key and as an autonumber
so that every time i add a new person, the personid automaticaaly
increments by 1.

now, my second form may be hard to explain. my form, frmContract, is
based on a query that includes both of my tables: person and contract.
i set up a query in the query design window. my query includes both
tables: person and contract. i set up a relationship line between
person.personid and contract.personid. i included *all* my fields from
both tables.

my form, frmContract, has all of the fields from the person table at
the top and all of the fields from the contract table at the bottom.
to open this form, i have a command button on another form that when
clicked opens up a blank frmContract. I have a combo box that is based
on the person table.

the combo box, cboPerson, has these 4 fields: personid, ss#, lastname,
firstname.

when i select a person, then all of the fields that are "person"
information are supposed to be populated. for example: after i select
a person in my combo box, the person fields (ss#, lastname, firstname,
address1, address2, city, state, zip, phone) are supposed to be
populated with the matching information. then once i start entering
data into one of the fields associated with the "contract"
information, i.e. startdate, the contractid autonumber field
automatically fills in with the next vavailable number. i say "supposed
to" because it doesn't.

let me give you a little background. the primary key of my person table
used to be ss#. but i wanted the possibility to add alternate address
information or other alternate information about the same person. so, i
added the personid field to my person table and made it both an
autonumber and the primary key.

when ss# was the primary key of my person table, the combo box on my
contract form worked ok. whenever i'd go to add a new contract, i'd
click the "add new contract" command button on my form, a new contract
form would pop up with the person fields blank and the contract fields
blank. then when i selected a person from the combo box (cboPerson had
the 3 fields: ss#, lastname, firstname), all of my "person" fields
would be populated with the correct information. for example: the last
name field would have the matching last name, the first name field
would have the matching first name, etc... only the "contract" fields
would be left blank. then once i started to enter any information into
any of the "contract" information fields (i.e. startdate), the
contractid autonumber field would automatically be populated with the
next available autonumber.

however after i added the new personid attribute to my person table and
changed the primary key from ss# to personid, i started to run into
these problems. i thought i could alter/ add a new combo box based on
personid and it would work. by the way, i added a text box to show the
ss#. but my new combo box was based on the fields: personid, ss#,
lastname, firstname. the combo box would store personid and the
attributes ss#, lastname, firstname in the combo box were added to
help discern one person from another.

so basically i'm stuck. now when i click on the combo box, it will open
but it makes an error noise when i try to select a person. it won't
let me select a person. it used to when i used ss# as the primary key
of my person table and as the foreign key in the contract table.

does anybody have any suggestions?

is it that my form doesn't like 2 autonumbers? i get an error, "control
can't be edited; it's bound to autonumber field 'personid.'

all of my fields on my form are bound to the fields from my query. my
query is based on both tables: person and contract.

is there a better way? what if i add a command button to the bottom of
my person form. this would some how open my contract form and then
populate all of the "person" information fields with the information
already entered on the person form. how would i automatically populate
all of the "person" information fields on the contract form?

thanks for reading my post! i know it's really long and redundant, but
i tried to be as clear as possible.

thanks,

megan

Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I believe you're going to do better with a form/subform setup. You'll need
to change the query in your frmContract form, and only show data in the
contract table. Drag this form into the frmPerson form, and you'll have a
subform which should automatically update based on the personid in the main
form. In other words, Access will do all of the work for you, and this form
will function like many standard Windows applications.

If you need more help, first look up forms/subforms in the help file, and
post additional questions to this site.

HTH
JV
<me**************@hotmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
hi everybody-

what is the best way to add data from one form to another?

i have 2 tables: person and contract. here are some of the fields.

table: person

personid (autonumber and primary key)
ss#
firstname
lastname
address1
adress2
city
state
zip
phone

table: contract
contractid (autonumber and primary key)
contracttype
startdate
enddate
employeeid
personid (foreign key to person table)

there is a 1 to many relationship between person and contract.

a person can have 1 or more contracts.
a contract can have 1 and only 1 person.
i have a question about 2 of my forms. my first form, frmPerson, is
based on the person table. it is a simple form to enter information
about a person. i used personid as the primary key and as an autonumber
so that every time i add a new person, the personid automaticaaly
increments by 1.

now, my second form may be hard to explain. my form, frmContract, is
based on a query that includes both of my tables: person and contract.
i set up a query in the query design window. my query includes both
tables: person and contract. i set up a relationship line between
person.personid and contract.personid. i included *all* my fields from
both tables.

my form, frmContract, has all of the fields from the person table at
the top and all of the fields from the contract table at the bottom.
to open this form, i have a command button on another form that when
clicked opens up a blank frmContract. I have a combo box that is based
on the person table.

the combo box, cboPerson, has these 4 fields: personid, ss#, lastname,
firstname.

when i select a person, then all of the fields that are "person"
information are supposed to be populated. for example: after i select
a person in my combo box, the person fields (ss#, lastname, firstname,
address1, address2, city, state, zip, phone) are supposed to be
populated with the matching information. then once i start entering
data into one of the fields associated with the "contract"
information, i.e. startdate, the contractid autonumber field
automatically fills in with the next vavailable number. i say "supposed
to" because it doesn't.

let me give you a little background. the primary key of my person table
used to be ss#. but i wanted the possibility to add alternate address
information or other alternate information about the same person. so, i
added the personid field to my person table and made it both an
autonumber and the primary key.

when ss# was the primary key of my person table, the combo box on my
contract form worked ok. whenever i'd go to add a new contract, i'd
click the "add new contract" command button on my form, a new contract
form would pop up with the person fields blank and the contract fields
blank. then when i selected a person from the combo box (cboPerson had
the 3 fields: ss#, lastname, firstname), all of my "person" fields
would be populated with the correct information. for example: the last
name field would have the matching last name, the first name field
would have the matching first name, etc... only the "contract" fields
would be left blank. then once i started to enter any information into
any of the "contract" information fields (i.e. startdate), the
contractid autonumber field would automatically be populated with the
next available autonumber.

however after i added the new personid attribute to my person table and
changed the primary key from ss# to personid, i started to run into
these problems. i thought i could alter/ add a new combo box based on
personid and it would work. by the way, i added a text box to show the
ss#. but my new combo box was based on the fields: personid, ss#,
lastname, firstname. the combo box would store personid and the
attributes ss#, lastname, firstname in the combo box were added to
help discern one person from another.

so basically i'm stuck. now when i click on the combo box, it will open
but it makes an error noise when i try to select a person. it won't
let me select a person. it used to when i used ss# as the primary key
of my person table and as the foreign key in the contract table.

does anybody have any suggestions?

is it that my form doesn't like 2 autonumbers? i get an error, "control
can't be edited; it's bound to autonumber field 'personid.'

all of my fields on my form are bound to the fields from my query. my
query is based on both tables: person and contract.

is there a better way? what if i add a command button to the bottom of
my person form. this would some how open my contract form and then
populate all of the "person" information fields with the information
already entered on the person form. how would i automatically populate
all of the "person" information fields on the contract form?

thanks for reading my post! i know it's really long and redundant, but
i tried to be as clear as possible.

thanks,

megan

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.