Consulting

Results 1 to 3 of 3

Thread: Solved: Enable Button Criteria

  1. #1

    Solved: Enable Button Criteria

    In the userform, a name must be selected in the txtOcc, last 4 number entered in txtSSN and at least 1 checkbox must be checked. If any these items mention complied with, the "Print" Button should be disabled.

    I manage to accomplish txtOcc, txtSSN, & Form 2106 ckbox. Unfortunately I can't seem to get the other checkboxes to work. Currently, if txtOcc or txtSSN is completed and I check either of the remaining checkbox, it enables the the "Print Button".

    for example, select Name1, leave txtSSN blank, then check Vehicle Expense. The "Print" button gets enabled when it not suppose to since txtSSN is empty.

    Can someone assist. Thanks
    Attached Files Attached Files

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [vba]Private Sub ck2106_Click()
    ChkVal
    End Sub

    Private Sub ckEER_Click()
    ChkVal
    End Sub

    Private Sub ckMER_Click()
    ChkVal
    End Sub

    Private Sub ckVER_Click()
    ChkVal
    End Sub

    Private Sub txtOcc_Change()
    ChkVal
    End Sub

    Private Sub txtSSN_Change()
    ChkVal
    End Sub

    Function ChkVal()
    Dim a&, b&, c&, d&, e&, f&, x&
    a = 1 * (txtOcc <> "")
    b = 1 * (txtSSN <> "")
    c = 4 * ck2106
    d = 4 * ckMER
    e = 4 * ckEER
    f = 4 * ckVER
    x = a + b + c + d + e + f
    If x Mod 4 = 0 Then
    Ent1.Enabled = False
    Else
    If x <= -6 And x Mod 2 = 0 Then
    Ent1.Enabled = True
    Else
    Ent1.Enabled = False
    End If
    End If
    End Function
    [/vba]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    Thank you Mack. It works great!

Posting Permissions

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