Field Values conditioned on Yes/No Box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wasseypurian
    New Member
    • Jun 2014
    • 9

    Field Values conditioned on Yes/No Box

    I have trying to validate the entry in another field say 'Amount' after user enters the value(Yes/No using check box) in the field 'Checkout'.

    How to make sure that I prompt user to enter a non zero amount in the 'Amount' field value if he enters 'Yes' in 'Checkout' field and leave it zero if chooses 'No'.
  • JenZzz
    New Member
    • May 2014
    • 9

    #2
    Could you be a bit more specific.
    If you simply want to check the value in your textbox and if it's empty, prompt the user to either enter or leave it 0 I would try something like this
    Code:
    If "" & Me.Textbox = "" Then
         answer = msgbox"Enter data?", vbYesNo
    End If
    If answer = vbYes Then
        'let the user enter his value
    Else
        me.textbox.value = 0
    End If

    Comment

    • twinnyfo
      Recognized Expert Moderator Specialist
      • Nov 2011
      • 3660

      #3
      I think you want to have this validation after the user checks the check box? If this is the case, then something along these lines:


      Code:
      Private Sub chkCheckBox_AfterUpdate()
          If Me.chkCheckBox Then
              If Me.txtAmount = 0 Then 'assuming default value here
                  MsgBox "You must enter an amount"
                  Me.chkCheckBox = False
                  Me.txtAmount.SetFocus
              End If
          Else
              Me.txtAmount = 0
          End If
      End Sub
      Hoep this hepps!

      Comment

      Working...