form to add records - plural (1 Viewer)

gfultz

Registered User.
Local time
Today, 02:27
Joined
Dec 18, 2009
Messages
51
I am trying to create a form that will add a record to the bound table and also to the related tables. I also would like to prevent the form from updating until the user clicks the add button. This will trigger the record save and then (ideally) the creation of a record in 3 other tables.

I have seen a thread on usinge the beforeupdate event, but I could not get that to function.

I have the following for my command buttons now:
Code:
Private Sub Cancel_Click()
On Error GoTo Err_Cancel_Click
If Me.Dirty Then
    DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
End If
    DoCmd.Close
Exit_Cancel_Click:
    Exit Sub
Err_Cancel_Click:
    MsgBox Err.Description
    Resume Exit_Cancel_Click
End Sub
 
Private Sub AddMR_Click()
On Error GoTo Err_AddMR_Click

    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Exit_AddMR_Click:
    Exit Sub
Err_AddMR_Click:
    MsgBox Err.Description
    Resume Exit_AddMR_Click
    
End Sub

I am assuming to add records to the other tables I could use the following after the save record command:
Code:
DoCmd.RunSQL "Insert INTO QUOTE(MRID) VALUES(" & Me.MRID & ")"
DoCmd.RunSQL "Insert INTO PO(MRID) VALUES(" & Me.MRID & ")"
DoCmd.RunSQL "Insert INTO PREQ(MRID) VALUES(" & Me.MRID & ")"

Thanks for the help!
 

gfultz

Registered User.
Local time
Today, 02:27
Joined
Dec 18, 2009
Messages
51
So I was correct on the sql code after setting the warniings to false and then turning them back on.

I would also like to now have the current form closed and open a new form on the record when the add button is clicked. The cancel button should cancel everything and close the form.

I just want to make sure someone can't create a record and then close the window without either cancelling the creation or creating the record throuhout the db.
 

Users who are viewing this thread

Top Bottom