spartansFC
Programmer
Hi
I'm trying to open a new blank record for data entry linked to whatever person/record i'm on.
For example, i if i want to add new bookings to record 1 (lngPeopleID). I should just be able to click on the new booking command button, the form should open with the correct lngPeopleID with blank fields to fill in.
Main form: frmCustomers (tblCustomers), lngPeopleID (PrimaryKey)
Subform (frmCustomersBookingSubform), qryBookings, lngBookingID (Primary Key), lngPeopleID (ForeignKey)
The subform on the main form is just for viewing only, it can't be edited and the user can only click on edit booking command button on the main form which brings up a pop up form which they can then edit, close it down which refreshes the subform again.
I know how to jump to a record to edit a booking via the subform with this:
Code:
Private Sub EditBooking_cmdbutton_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmAddEditBookings"
If Me.Dirty Then Me.Dirty = False
DoCmd.OpenForm stDocName, , , stLinkCriteria, , , Me![frmCustomersBookings Subform].Form![lngBookingID]
Exit_EditBooking_cmdbutton_lest_Click:
Exit Sub
Err_EditBooking_cmdbutton_lest_Click:
MsgBox Err.Description
Resume Exit_EditBooking_cmdbutton_lest_Click
End Sub
I just want to be able to add a new booking to a new persons record, i did try:
Code:
Private Sub AddNewBooking_cmdbutton_Click()
On Error GoTo Err_AddNewBooking_cmdbutton_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmAddNewBooking"
DoCmd.OpenForm stDocName, , , stLinkCriteria, , , Me.lngPeopleID
DoCmd.GoToRecord , , acNewRec
Exit_AddNewBooking_cmdbutton_Click:
Exit Sub
Err_AddNewBooking_cmdbutton_Click:
MsgBox Err.Description
Resume Exit_AddNewBooking_cmdbutton_Click
End Sub
All this does is open a blank record but it isn't linked to the person, i do have the OpenArgs in the OnLoad event of the form
Code:
Private Sub Form_Load()
If Len(Me.OpenArgs) > 0 Then
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[lngPeopleID]=" & Me.OpenArgs
Me.Bookmark = rs.Bookmark
End If
End Sub
Just can't figure it out
Michael