How would i enable a command button after 3 or 4 text boxes have been filled in?????

Posted on 2004-10-23
Last Modified: 2010-05-02
How would i enable a command button after 3 or 4 text boxes have been filled in.  I want the user to fill the text boxes in with the info and once ALL the text boxes are filled in i then want the command button to become enabled so they can move onto the next area???
I am using VB6.


Question by:On_The_Level
    LVL 11

    Expert Comment

    JUst run a check procedure in the lost focus or keypress event of the text boxes


    sub textbox1_lostfocus()
    end sub


    sub checkValadation()
      if (len(textbox1.text ) > 0 ) then
        if (len(textbox2.text ) > 0 ) then
          if (len(textbox3.text ) > 0 ) then
            cmdOk.enabled = true
          end if
        end if
      end if
    end sub

    LVL 48

    Accepted Solution

    or if you want instant effect, you can try put the validation code to the Changed event instead. like:

    Private Sub Text1_Change()
    End Sub

    Private Sub Text2_Change()
    End Sub

    Private Sub Text3_Change()
    End Sub

    Private Sub Text4_Change()
    End Sub

    Private Sub chkEnable()
        Command1.Enabled = IIf(Len(Text1) > 0 And Len(Text2) > 0 And Len(Text3) > 0 And Len(Text4) > 0, True, False)
    End Sub

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

     Java Android Coding Bundle

    Whether you're an Apple user or Android addict, learning to code for the Android platform is an extremely valuable, in-demand skill. It all starts with Java, the language behind the apps and games that make Android the top platform it is today.

    Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
    Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    846 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now