Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2005

    Unanswered: Textbox validation

    I can't get this to work.

    I have a form with 2 textboxes. In front of each of these textboxes are option buttons.

    If the user selects the option button in front of the Text2 textbox, I need the user to enter a value between $100 and $500.

    If they enter nothing, OR enter a value outside of this range, OR they enter any non-numeric chars, I want a message box to pop up and the field's background to turn yellow. They are not to be allowed out of this box until they enter a valid value, OR they un-selected the option button in front of the text box.

    If they enter a valid value, they should be able to proceed to the next field.

    Private Sub Option0_Click()
    If Me.Option0 = True Then
        Me.Option0 = False
        Me.Text2 = Null
    End If
    End Sub
    Private Sub Text2_BeforeUpdate(Cancel As Integer)
    If Me.Option0 = False Then
        Me.Text2 = Null
        If Len(Me.Text2 & vbNullString) = 0 Or IsNumeric(Me.Text2) = False Or Me.Text2 < 100 Or Me.Text2 > 500 Then
            MsgBox ("Can not be empty or hold any non numeric characters or be outside of $100 - $500...correct it!")
            Cancel = True
        End If
    End If
    End Sub

  2. #2
    Join Date
    Jan 2005
    Erm... no one replys to you yet?

    Hmm, do u mean u have the button in the first form, and once u clicked it, it willl lead to the textbox in the second form?

    If thats the case, i think u need to specify the form2.setfocus and setfocus to ur textbox..

    Anyway, what is the error shown?

Posting Permissions

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