Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using inputbox to find a record 1

Status
Not open for further replies.

MikeGeitner

Technical User
Aug 11, 2005
59
US
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?

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
 
How about:

Code:
strInput=InputBox("Enter the " _
        & "deviation number", "Go To Deviation") 

If strInput = "" Then Exit Sub
  
strDev = "[FullDev] Like '*" & strInput & "*'"
 
Remou,

That works perfectly. Have a star!

Thanks,

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top