Results 1 to 3 of 3

Thread: FORM - goto first text box if not found

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Tutor
    Joined
    Oct 2007
    Posts
    210
    Location

    FORM - goto first text box if not found

    I have a pop up entry form that asks for the order number. If found it fills in some read-only data and then follows the tab order to the next text box. However, if the order number is not found a message box appears stating so. The tab order is still followed and goes to the next text box. On not found I want it to go back to the first box for retry. Please help. Code below.

    [vba]Private Sub txtOrderNumber_AfterUpdate()
    With Worksheets("Data")
    For Each orderNumber In Range("colOrderNumber")
    If orderNumber.Value = txtOrderNumber.Value Then
    ' lightSwitch turnOn:=True
    currentRecord = orderNumber.Row
    Me.txtSystemQuantity.Value = .Cells(currentRecord, 8)
    Me.txtSystemWeight.Value = .Cells(currentRecord, 11)
    Me.txtActualQuantity.Value = .Cells(currentRecord, 16)
    Me.txtActualWeight.Value = .Cells(currentRecord, 17)
    Me.cboBarrelType.Text = .Cells(currentRecord, 18)

    Exit For
    End If
    If IsEmpty(orderNumber) Then
    MsgBox Prompt:=Me.txtOrderNumber.Value, Title:="Record Not Found"
    Me.txtOrderNumber.Value = ""
    ' lightSwitch turnOn:=False
    Exit Sub
    End If
    Next orderNumber
    End With
    End Sub[/vba]
    Last edited by Aussiebear; 09-07-2010 at 03:42 PM. Reason: Applied VBA tags to code
    "The amount of stupid people in the world is God's way of punishing the smart people" - protean_being

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •