Connecting forms

S

slhenson

I am using MS Access 2000. I have 2 forms. I am trying to pull 2 fields from
the 1st form to automatically populate those fields in the 2nd form when I go
to it from the 1st form.
 
R

Rick Brandt

slhenson said:
I am using MS Access 2000. I have 2 forms. I am trying to pull 2 fields from
the 1st form to automatically populate those fields in the 2nd form when I go
to it from the 1st form.

Three ways (OTTOMH)

1) First form "pushes" entries into second one

DoCmd.OpenForm "SecondForm"
Forms!SecondForm!ControlName = Me.SomeControl

2) Second form "pulls" entries from first form in its Open event

Me.ControlName = Forms!FirstForm!ControlName

3) Set the default value property for control in second form to...

=Forms!FirstForm!ControlName

The first two have the disadvantage that the second form is automatically
"dirtied" so the user will either have to finish creaing a record or know
to use the <Escape> key to cancel. The third option does not dirty the
second form so unless the user actually types something else no record will
be started.
 
J

JL

Hi slhenson,

On the "Form open" event on the second form. The fields will only populate
on the form first open.

Private Sub Form_Open(Cancel As Integer)
Me![Field1] = [Forms]![FirstForm]![Field1]
Me![Field2] = [Forms]![FirstForm]![Field2]
End Sub
 
S

slhenson

JL

I tried the code that you sent. I get an error message saying that "You
can't assign a value to this object" and it goes to the line of code that
says

Me![Field1] = [Forms]![FirstForm]![Field1]

I inserted my field name and form name of course. Can you help me with what
I have done wrong?

slhenson

JL said:
Hi slhenson,

On the "Form open" event on the second form. The fields will only populate
on the form first open.

Private Sub Form_Open(Cancel As Integer)
Me![Field1] = [Forms]![FirstForm]![Field1]
Me![Field2] = [Forms]![FirstForm]![Field2]
End Sub

slhenson said:
I am using MS Access 2000. I have 2 forms. I am trying to pull 2 fields from
the 1st form to automatically populate those fields in the 2nd form when I go
to it from the 1st form.
 
R

Rick Brandt

slhenson said:
JL

I tried the code that you sent. I get an error message saying that "You
can't assign a value to this object" and it goes to the line of code that
says

Me![Field1] = [Forms]![FirstForm]![Field1]

I inserted my field name and form name of course. Can you help me with what
I have done wrong?

If you assign to a "field" as opposed to a "control" you might have to wait
until the Load event as the Open event might be too soon to have access to
the Fields collection.
 
J

JL

Hi slhenson,

I have a similar situation. It worked for me.
The "Me![Field1]" is the current form (second form text box) textbox that
you are trying to open. The "[Forms]![FirstForm]![Field1]" is the textbox
from first form.
The "Form_Open" event will only occur when the form opens. Not any other
time.

Me![Field1] = [Forms]![FirstForm]![Field1]

I hope this clears up.

slhenson said:
JL

I tried the code that you sent. I get an error message saying that "You
can't assign a value to this object" and it goes to the line of code that
says

Me![Field1] = [Forms]![FirstForm]![Field1]

I inserted my field name and form name of course. Can you help me with what
I have done wrong?

slhenson

JL said:
Hi slhenson,

On the "Form open" event on the second form. The fields will only populate
on the form first open.

Private Sub Form_Open(Cancel As Integer)
Me![Field1] = [Forms]![FirstForm]![Field1]
Me![Field2] = [Forms]![FirstForm]![Field2]
End Sub

slhenson said:
I am using MS Access 2000. I have 2 forms. I am trying to pull 2 fields from
the 1st form to automatically populate those fields in the 2nd form when I go
to it from the 1st 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