Guest_imported
New member
- Jan 1, 1970
- 0
I have an index set on two fields in my database, SLIC and DATE. Therefore for every SLIC entry there can only be one date. On my form, the first two fields they enter are the SLIC and DATE. If they enter a SLIC and DATE that already exist I want it to pull the record and display it for editing etc. I'm using the On Exit event handler. This is the code I have so far.
I know that it is finding the record after trial and error, however I'm getting the following error:
"Microsoft Access Run-time Error '2105':
You can't go to the specified record.
You may be at the end of a recordset."
Here is my code:
Private Sub DATE_Exit(Cancel As Integer)
Dim db As DAO.Database, rst As DAO.Recordset
Dim strSearchName As String
Set rst = Me.RecordsetClone
strSearchName = "[SLIC] = " & Me![SLIC] & "AND [DATE] = #" & Me![DATE] & "#"
rst.FindFirst strSearchName
If rst.NoMatch Then
Exit Sub
Else
Me.Bookmark = rst.Bookmark
End If
rst.Close
End Sub
I know that it is finding the record after trial and error, however I'm getting the following error:
"Microsoft Access Run-time Error '2105':
You can't go to the specified record.
You may be at the end of a recordset."
Here is my code:
Private Sub DATE_Exit(Cancel As Integer)
Dim db As DAO.Database, rst As DAO.Recordset
Dim strSearchName As String
Set rst = Me.RecordsetClone
strSearchName = "[SLIC] = " & Me![SLIC] & "AND [DATE] = #" & Me![DATE] & "#"
rst.FindFirst strSearchName
If rst.NoMatch Then
Exit Sub
Else
Me.Bookmark = rst.Bookmark
End If
rst.Close
End Sub