Hello all,
I have a main form (frmAssignmentChanges), with two subforms (fsubSearchChange, fsubViewChange). One or other of the subforms will be visible at any one time, never both, so my code switches between the two depending on which combobox is used. Both subforms use the ControlSource (tblAssignmentChanges).
fsubSearchChange is a Continuous Form
fsubViewChange is a Single Form
fsubViewChange is made visible through the AfterUpdate event of my combobox (cboSearchByP1). The code should also bookmark the subform to the related combobox choice. Instead though, I receive an error message "run-time error 2001 - you canceled the previous operation". Ironically though, if I substitute my code to reference the other subform (fsubSearchChange), because they're both using the same control source, the subform jumps to the correct record fine.
Because of this, I don't think there's an issue with the code. But what else could be causing the error, and failure to bookmark when I use fsubViewChange?
I've posted my code below in case this helps:
Dim rs As Object
Me.fsubSearchChange.Visible = False
Me.fsubViewChange.Visible = True
Set rs = Me.fsubViewChange.Form.Recordset.Clone
rs.FindFirst "[autChangeNumber] = " & Str(Nz(Me![cboSearchByP1], 0))
If Not rs.EOF Then Me.fsubViewChange.Form.Bookmark = rs.Bookmark
rs.Close
Set rs = Nothing
When debugging, the error occurs on this line:
Me.fsubViewChange.Form.Bookmark = rs.Bookmark
Hope someone can help!
I have a main form (frmAssignmentChanges), with two subforms (fsubSearchChange, fsubViewChange). One or other of the subforms will be visible at any one time, never both, so my code switches between the two depending on which combobox is used. Both subforms use the ControlSource (tblAssignmentChanges).
fsubSearchChange is a Continuous Form
fsubViewChange is a Single Form
fsubViewChange is made visible through the AfterUpdate event of my combobox (cboSearchByP1). The code should also bookmark the subform to the related combobox choice. Instead though, I receive an error message "run-time error 2001 - you canceled the previous operation". Ironically though, if I substitute my code to reference the other subform (fsubSearchChange), because they're both using the same control source, the subform jumps to the correct record fine.
Because of this, I don't think there's an issue with the code. But what else could be causing the error, and failure to bookmark when I use fsubViewChange?
I've posted my code below in case this helps:
Dim rs As Object
Me.fsubSearchChange.Visible = False
Me.fsubViewChange.Visible = True
Set rs = Me.fsubViewChange.Form.Recordset.Clone
rs.FindFirst "[autChangeNumber] = " & Str(Nz(Me![cboSearchByP1], 0))
If Not rs.EOF Then Me.fsubViewChange.Form.Bookmark = rs.Bookmark
rs.Close
Set rs = Nothing
When debugging, the error occurs on this line:
Me.fsubViewChange.Form.Bookmark = rs.Bookmark
Hope someone can help!