Changing record on subform datasheet

nikmav

New member
Local time
Today, 11:32
Joined
Feb 9, 2011
Messages
8
Hi, this is driving me mental if anyone can help I'd greatly appreciate it. So basically I have the following forms:

Main Form called Customers
Sub Form to Main Form called Service1
Sub Form to Main Form called ServiceDataSheet (Same as Service but in datasheet view)

If you haven't guessed already Im trying to create a split form as a sub form which isn't a feature (Thanks Microsoft!).

Anyway so when a user clicks on a record in the ServiceDataSheet form the Service form shows the detail, I have this working nicely with the following:
Code:
Private Sub Form_Current()

DoCmd.RunCommand acCmdSaveRecord

Dim rst As Recordset
Set rst = Forms!Customers.ServiceDataSheet.Form.RecordsetClone

If Not IsNull(Me.ServiceID) Then
rst.FindFirst "ServiceID = " & Me.ServiceID
    Forms!Customers.Service1.Form.Bookmark = rst.Bookmark
Else

Forms!Customers.Service1.SetFocus
DoCmd.GoToRecord , , acNewRec
End If

rst.Close
Set rst = Nothing
End Sub
The problem is when the user changes records in the Service1 form (detail), the ServiceRecordSheet doesn't move when I use this:

Code:
Private Sub Form_Current()

DoCmd.RunCommand acCmdSaveRecord

Dim rst As Recordset
Set rst = Forms!Customers.Service1.Form.RecordsetClone

'change here to reflect your key
If Not IsNull(Me.ServiceID) Then
rst.FindFirst "ServiceID = " & Me.ServiceID
    Forms!Customers.ServiceDataSheet.Form.Bookmark = rst.Bookmark
Else

Forms!Customers.ServiceDataSheet.SetFocus
DoCmd.GoToRecord , , acNewRec
End If

rst.Close
Set rst = Nothing
End Sub
I get a Run-time error '2445: You entered an expression that has an invalid reference to the property Form / Report.

Does anyone have any suggestions on what Im doing wrong or know a way to make a split form sub form a different way?

Cheers
 
Make sure that when you reference your subforms that you refer to the subform CONTROL (control on the main form which houses the subform) name and not the subform name itself (unless they share the exact same name).
 

Users who are viewing this thread

Back
Top Bottom