Another data field validation question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jayjayplane
    New Member
    • Sep 2008
    • 26

    Another data field validation question

    Thanks everybody here answered my last data field validation question about the alert of future date.

    Here I get another question, sorry, I am really an Access newbie...

    The question is :

    I have a couple of list fields, one of the field will pop up only based on the upper list field value is true, for example, list field "individual_ses sion" and list field "nationalit y", the nationality field will pop up and ready to choose the value only when individual_sesi on value is true, otherwise the nationality field shows gray (the individual_sess ion value is false, the list field nationality isn't enabled).

    Thanks million
  • jayjayplane
    New Member
    • Sep 2008
    • 26

    #2
    some mistake here, there are combo box for individual_sess ion and nationality rather than list field.

    I am online waiting , anybody can help?

    Comment

    • jayjayplane
      New Member
      • Sep 2008
      • 26

      #3
      why nobody helped me today, i didn't explain the question very clear?

      My supervisor didn't give me a lot of time to work on it, and I also tried many ways, but still didn't walk through...

      Experts, please help....

      Comment

      • jayjayplane
        New Member
        • Sep 2008
        • 26

        #4
        the question right now can like this:


        I have a couple of combo box fields, one of the field will pop up only based on the upper field value is "true", for example, field "individual_ses sion" and field "nationalit y", the nationality field will pop up and ready to choose the value only when individual_sesi on value is "true", otherwise the field nationality will be forced to fill blank.


        Thanks million

        Comment

        • beacon
          Contributor
          • Aug 2007
          • 579

          #5
          Originally posted by jayjayplane
          the question right now can like this:


          I have a couple of combo box fields, one of the field will pop up only based on the upper field value is "true", for example, field "individual_ses sion" and field "nationalit y", the nationality field will pop up and ready to choose the value only when individual_sesi on value is "true", otherwise the field nationality will be forced to fill blank.


          Thanks million
          Hi JJP,

          These combo box fields are on a form, correct? Are you saying that when the user enters something into the "individual_ses sion" that the "nationalit y" field becomes enabled?

          If that's the case, then one of the combo boxes should be set to enabled, while the other will be set to disabled. Then you can enter VBA code to test whether or not the first combo box has a value in it and, depending on the answer, can code the second field to be enabled.

          For instance:
          Code:
          If Not IsNull(Me.Individual_Session) then
               Me.Nationality.Enabled = True
          End If
          You might even want to put something into the OnLoad event for the form to ensure that the Nationality field is disabled to start off with each time.

          I hope this helps...

          Comment

          • jayjayplane
            New Member
            • Sep 2008
            • 26

            #6
            data field validation

            Thank you very much, yes, it is a form with some combo box, both individual_sess ion and nationality are combo boxes, where individual_sess ion can select value " true" or "false", and for nationality, the data source is from table nationailty, so there are lists of nationality to be chozen. But only when the user select individual_sess ion is "True", then nationality is avaible to be selected from a drop down list...
            Last edited by jayjayplane; Sep 30 '08, 07:59 PM. Reason: typo

            Comment

            • beacon
              Contributor
              • Aug 2007
              • 579

              #7
              Ok, then the following code...
              Code:
              If Not IsNull(Me.Individual_Session) Then
                   Me.Nationality.Enabled = True
              End If
              ...needs to change to the following
              Code:
              If Me.Individual_Session.Value = "True" Then
                   Me.Nationality.Enabled = True
              End If

              Comment

              • jayjayplane
                New Member
                • Sep 2008
                • 26

                #8
                Originally posted by beacon
                Ok, then the following code...

                ...needs to change to the following
                Code:
                If Me.Individual_Session.Value = "True" Then
                     Me.Nationality.Enabled = True
                End If

                but It gave me compile error:


                method or data member not found and Me.Nationality. Enabled = True where "Enable" was highlighted

                Comment

                • beacon
                  Contributor
                  • Aug 2007
                  • 579

                  #9
                  What event are you using?

                  I created a combobox (Box1) and went chose the event procedure for OnChange.

                  The code ends up looking like this:
                  Code:
                  Private Sub Box1_Change()
                       if me.box1.value = "True" then
                            me.box2.enabled = True
                       else
                            me.box2.enabled = False
                       end if
                  End Sub
                  This assumes that you've already set your Box1's 'Enabled' property to 'No' and that in the form's Load event you've typed in something like the following:
                  Code:
                  Private Sub Form_Load()
                       me.box2.enabled = False
                  End Sub

                  Comment

                  • jayjayplane
                    New Member
                    • Sep 2008
                    • 26

                    #10
                    Originally posted by beacon
                    What event are you using?

                    I created a combobox (Box1) and went chose the event procedure for OnChange.

                    The code ends up looking like this:
                    Code:
                    Private Sub Box1_Change()
                         if me.box1.value = "True" then
                              me.box2.enabled = True
                         else
                              me.box2.enabled = False
                         end if
                    End Sub
                    This assumes that you've already set your Box1's 'Enabled' property to 'No' and that in the form's Load event you've typed in something like the following:
                    Code:
                    Private Sub Form_Load()
                         me.box2.enabled = False
                    End Sub

                    Thanks beacon, it showed me something I wanted...
                    bow!

                    Comment

                    • jayjayplane
                      New Member
                      • Sep 2008
                      • 26

                      #11
                      Still gave me compile error message,
                      right now I set box2 nationality enable=no
                      and select box1 individual_sess ion "false" from drop down menu, box2 is gray as expected, but when I select box1 individual_sess ion "True", didn't enable the box2 as expected but gave me the compile error.
                      the code here is:

                      Private Sub s1_individual_s ession_Change()
                      If Me.s1_individua l_session.Value = "True" Then
                      Me.s1_nationali ty1.Enabled = True

                      End If
                      End Sub

                      Me.s1_nationali ty1.Enabled = True where Enabled is highlighted

                      Comment

                      • beacon
                        Contributor
                        • Aug 2007
                        • 579

                        #12
                        Does the individual_sess ion pull the true/false values that populate the combobox from a table?

                        On the table, are the true/false values entered as a text string or is the field set up as a yes/no field?

                        Comment

                        • jayjayplane
                          New Member
                          • Sep 2008
                          • 26

                          #13
                          Originally posted by beacon
                          Does the individual_sess ion pull the true/false values that populate the combobox from a table?

                          On the table, are the true/false values entered as a text string or is the field set up as a yes/no field?

                          On the form the combo box individual_sess ion pulls the true/false values from the value list rather than from a table, but the underlying the table, I set individual_sess ion as text type, but on the form I set individual_sess ion as combo box that contains list value "True" and "False"

                          Thank you

                          Comment

                          Working...