open form, add new record, and set a value in that new record

csoseman

Registered User.
Local time
Today, 09:52
Joined
Aug 18, 2011
Messages
28
I have a button(cmd1) on a form(Form1) that I want to have open a different form(Form2) to add more detailed information, add a new record, and set a field in Form2 equal to the primary key of Form1 without having to add Form2 as a subform. Anyone know of any ideas or have code for that?
 
In The calling or original form
Code:
Private Sub Go2SecondaryForm_Click()

If Not IsNull(Me.ID) Then
  DoCmd.OpenForm "SecondaryFormName", , , , , , Me.ID
 Else
  MsgBox "An ID Must Be Entered First!"
 End If

End Sub
In the called form (SecondaryFormName in this example)
Code:
Private Sub Form_Load()

If Not IsNull(Me.OpenArgs) Then
    DoCmd.GoToRecord , , acNewRec
    Me.ID = Me.OpenArgs
 End If

End Sub
Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom