Second form with primary key from main form

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

Guest

I have about 20 forms in an old database used to record equipment delay time.
Users open a form and a delay start time is automatically entered. When
equipment is back online, a button is clicked to enter delay time. I would
like to create a button on delay form that would open a repair form. Primary
key on delay form would be foreign key on repair form. How do I correctly
code repair form to use primary key from whichever equipment delay form is
open? thanks
 
The code behind the command button would include the following:

strFormName = "frmEquipmentRepair"
DoCmd.OpenForm strFormName
Forms(strFormName).EquipmentID = Me.EquipmentID
DoCmd.Close Me.Name

which opens the repair form, and sets the ID value on the newly opened
form to the one in the current form (Me. translates to "this form" in
plain english). The last line closes the current form.
Hope my naming assumptions are self-evident, so you can substitute the
actual form and control names.

HTH,
Nikos
 
Nikos Yannacopoulos said:
The code behind the command button would include the following:

strFormName = "frmEquipmentRepair"
DoCmd.OpenForm strFormName
Forms(strFormName).EquipmentID = Me.EquipmentID
DoCmd.Close Me.Name

which opens the repair form, and sets the ID value on the newly opened
form to the one in the current form (Me. translates to "this form" in
plain english). The last line closes the current form.
Hope my naming assumptions are self-evident, so you can substitute the
actual form and control names.

HTH,
Nikos

Nikos, your code was huge help. Thanks for your time. Eb1mom
 
Back
Top