MikeGeitner
Technical User
Hello,
I'm using an inputbox to move a form to the desired record.
If you "cancel" out of the inputbox, the form moves to the first record. How can I stop that?
I'm using an inputbox to move a form to the desired record.
If you "cancel" out of the inputbox, the form moves to the first record. How can I stop that?
Code:
Private Sub cmdGoTo_Click()
Dim rst As DAO.Recordset
Dim strDev As String
Set rst = Me.RecordsetClone
On Error GoTo cmdGoTo_Click_Error
strDev = "[FullDev] Like '*" & InputBox("Enter the " _
& "deviation number", "Go To Deviation") & "*'"
rst.FindFirst strDev
If rst.NoMatch Then
MsgBox "No deviation was found", vbInformation
Else
Me.Bookmark = rst.Bookmark
Me.Recalc
End If
Set rst = Nothing
On Error GoTo 0
Exit Sub
cmdGoTo_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") while looking for a matching deviation"
End Sub