Same field on secondary form displaying info from primary form.

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

Guest

This is probably a dumb question, but I couldn't find in any of my books how
to do this, so here it is.

I have a form to input Lot numbers for a product, which we will call Form A.
There is detailed information that is to go with each lot number, which we
call Form B. I have a button on the form that opens up another form, in which
the user can input the detailed information. I want this Lot Number that is
typed in Form A to appear in Form B. How do I do this?

Example:

Form A.

Lot: Q123456

"click button to enter details"

Form B opens.

Lot: Q123456 (this field needs to automatically display the Lot # from Form A)
Field 1:
Field 2:
Etc.

Can anyone help me with this? When I try it, it either gives me a #NAME
error in which nothing displays and says it's controlled by another value, or
I have to retype the lot number again.
 
In the code of the On Click for your command button on Form A,
after you open the Form B, add a line such as
Forms.FormB.Lot = Me.TextLot

You do not have to set the control source on Form B, and
you can turn on the locked property if you do not want the
user to modify the value.
 
How would I apply that into VBA? I kind of copied a VBA when making the
button to open the child form. So I have this:

Sub ToggleLink_Click()
On Error GoTo ToggleLink_Click_Err
If ChildFormIsOpen() Then
CloseChildForm
Else
OpenChildForm
FilterChildForm
End If
ToggleLink_Click_Exit:
Exit Sub
ToggleLink_Click_Err:
MsgBox Error$
Resume ToggleLink_Click_Exit
End Sub

The whole thing is rather lengthy, but I am not sure if you need the whole
thing.
 
Back
Top