G
Guest
I have this routine to get to a particular record base on a value entered
into a text box. This value is compared to a field value [RecNo] to get the
matching record. I am OK when entering a value that the routine can find,
but if I enter a nonexitent value, it always goes to the first record (which
also happens to have a RecNo = 1).
Another question I have is that I don't understand the "rs.edit" that I seem
to need, or I get an error message regarding "Update or CancelUpdate without
AddNew or Edit"
The routine I created is:
Private Sub FindIt_AfterUpdate()
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
rs.Edit
rs.FindFirst "[RecNo] = " & Str(Nz(Me![FindIt], 0))
Debug.Print [RecNo]
If Not rs.EOF Then
Me.Bookmark = rs.Bookmark
Else
MsgBox "You entered a nonexitent record number", vbExclamation,
"Warning"
bytNoRec = True
Me!SeqNo.SetFocus
Me!FindIt.SetFocus
Me!FindIt = Null
rs.Close
Set rs = Nothing
Exit Sub
End If
End Sub
Thanks for any help. You can also email any help to: photopro at (leave
this out) cox dot net.
into a text box. This value is compared to a field value [RecNo] to get the
matching record. I am OK when entering a value that the routine can find,
but if I enter a nonexitent value, it always goes to the first record (which
also happens to have a RecNo = 1).
Another question I have is that I don't understand the "rs.edit" that I seem
to need, or I get an error message regarding "Update or CancelUpdate without
AddNew or Edit"
The routine I created is:
Private Sub FindIt_AfterUpdate()
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
rs.Edit
rs.FindFirst "[RecNo] = " & Str(Nz(Me![FindIt], 0))
Debug.Print [RecNo]
If Not rs.EOF Then
Me.Bookmark = rs.Bookmark
Else
MsgBox "You entered a nonexitent record number", vbExclamation,
"Warning"
bytNoRec = True
Me!SeqNo.SetFocus
Me!FindIt.SetFocus
Me!FindIt = Null
rs.Close
Set rs = Nothing
Exit Sub
End If
End Sub
Thanks for any help. You can also email any help to: photopro at (leave
this out) cox dot net.