Switch between forms and pass data

B

Brian C

I have form1 based upon table1 and form2 based upon table2.

I want to use data input in form1 to get a record from
table1 and if a certain value exits go to form2. Data is
then input in form2 and used to create a record in table2.
I then want to go update the read from table1 with some of
the data from the table2 record.

How do I achieve this?

Do I have to keep form1 open switch to form2 and then
switch back to form 1?

How do I ensure that the original form1 is activated and
not a new form1 so that the record is available?

How do I make the data from form2 available in form1 to
update the record?

I assume that I would have to do this using code so in
what events for each form would I piut the code?

How do I switch between forms using Access Basic code?

By the way could I somehow make the record selected from
table1 in form1 available in form2 so that I don't have to
keep form1 open and switch back?

Thanks for your help.
 
K

Katrina

do you have a problem with using a main form for table1 and a subform for
table2? If you did that you could set default values for new records on the
subform(table2) to values on the main form(table1) and set values for the
main form(table1) to whatever values you need from table2 in the on update
even for the subform(table2).

I hope this makes sense!
HTH
Kat
 
J

Jonathan Smith

Katrina,

Care to elaborate?

I have a MainForm, and 4 Subforms.

On the MainForm I INPUT Patient#. I would then like the Patient# to
automatically flow to the 4 subforms.

Thanks in Advance.

Jon
 
K

Katrina

Set the default value for the field on your subform (that represents the id
from the main form) to the value on your main form.
1. be sure to save the main form record before entering the subform.
2. subform
in the default value for the field that represent the id from the
mainform put
= forms!mainformname!idfieldname
so if your main forms name is frmPatientMain and the id field is
txtPatientID, the dafault value for the patientID on the suborms should look
like this
= forms!frmPatientMain!txtPatientID


HTH
Kat
 
J

John Vinson

On the MainForm I INPUT Patient#. I would then like the Patient# to
automatically flow to the 4 subforms.

If the Patient# field is in the Master Link Field and Child Link Field
properties of each subform, it will do so automatically. It won't
create a new record in the subform (and shouldn't - empty placeholder
records are essentially never a good idea), but when you add data to
any other field on the subform it will fill in.

That's assuming you're actually using a Subform rather than using code
to open up a second stand-alone form.
 
J

Jonathan Smith

Thank you, I will give it a try.

Set the default value for the field on your subform (that represents
the id from the main form) to the value on your main form.
1. be sure to save the main form record before entering the subform.
2. subform
in the default value for the field that represent the id from the
mainform put
= forms!mainformname!idfieldname
so if your main forms name is frmPatientMain and the id field is
txtPatientID, the dafault value for the patientID on the suborms
should look like this
= forms!frmPatientMain!txtPatientID


HTH
Kat
 
J

Jonathan Smith

Thanks John, I will give it a shot.

If the Patient# field is in the Master Link Field and Child Link Field
properties of each subform, it will do so automatically. It won't
create a new record in the subform (and shouldn't - empty placeholder
records are essentially never a good idea), but when you add data to
any other field on the subform it will fill in.

That's assuming you're actually using a Subform rather than using code
to open up a second stand-alone form.
 

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