S
Seren
I have a form with a subform in it. When a tool number is entered in the
subform, if it already exists in the table, I want that record to be returned
to the subform to populate the remaining fields in that subform. I am having
a problem with my code... I get an error on the Me.Bookmark = rsc.Bookmark
line. The tooltip says Me.Bookmark = <No Current Record.>
Anyone have any suggestions for me?
Thanks a bunch!
Seren
Private Sub ToolNum_BeforeUpdate(Cancel As Integer)
Dim TNum As String
Dim stDup As String
Dim rsc As dao.Recordset
Set rsc = Form_subTool.RecordsetClone
TNum = Form_subTool.ToolNum.Value
stDup = "ToolNum = " & "'" & TNum & "'"
' check if toolnum already exists in tblTool
If DCount("ToolNum", "tblTool", stDup) > 0 Then
' clear toolNum field
Me.Undo
' set form to existing matching record
rsc.FindFirst stDup
Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub
subform, if it already exists in the table, I want that record to be returned
to the subform to populate the remaining fields in that subform. I am having
a problem with my code... I get an error on the Me.Bookmark = rsc.Bookmark
line. The tooltip says Me.Bookmark = <No Current Record.>
Anyone have any suggestions for me?
Thanks a bunch!
Seren
Private Sub ToolNum_BeforeUpdate(Cancel As Integer)
Dim TNum As String
Dim stDup As String
Dim rsc As dao.Recordset
Set rsc = Form_subTool.RecordsetClone
TNum = Form_subTool.ToolNum.Value
stDup = "ToolNum = " & "'" & TNum & "'"
' check if toolnum already exists in tblTool
If DCount("ToolNum", "tblTool", stDup) > 0 Then
' clear toolNum field
Me.Undo
' set form to existing matching record
rsc.FindFirst stDup
Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub