color subform tab when text boxes are filled

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ielamrani
    New Member
    • Feb 2007
    • 72

    color subform tab when text boxes are filled

    Hi,
    I am trying to color a subform tab blue or red when 2 of its text boxes are
    not null. Here is my code that I tried but it's not working:

    If Forms![Centers of Influence subform].First Is Not Null And Forms![Centers
    of Influence subform].Last Is Not Null Then
    Forms![Centers of Influence subform].Page4781 = RGB(0, 0, 255) 'blue
    Else
    Forms![Centers of Influence subform].Page4781 = RGB(0, 0, 0) 'black

    End If

    can anyone tell me what's wrong with my code?
    First and Last are the name of the text boxes in the subform.

    Thanks in advance
  • puppydogbuddy
    Recognized Expert Top Contributor
    • May 2007
    • 1923

    #2
    Originally posted by ielamrani
    Hi,
    Here is my code that I tried but it's not working:

    If Forms![Centers of Influence subform].First Is Not Null And Forms![Centers of Influence subform].Last Is Not Null Then
    Forms![Centers of Influence subform].Page4781= RGB(0, 0, 255) 'blue
    Else
    Forms![Centers of Influence subform].Page4781 = RGB(0, 0, 0) 'black
    End If

    You need to provide some more details on what "not working" means in this context.....com pile error, runtime error, any error messages? Also is this code running from the subform or from the Main Form?

    In looking at your code (pending further information), it appears to be a problem with your reference syntax. For example if your code is running from your MainForm, your reference should be like this:

    Forms![YourMainForm]![Centers of Influence subform].Form!First

    If it is running from your subform, your code syntax should look something like this:
    Me!First = .........

    Comment

    • ielamrani
      New Member
      • Feb 2007
      • 72

      #3
      Thanks for your reply.
      The code is running from the Main Form (On Open) so I changed the code to look like this:

      If Forms![Client Maintenance Center Search]![Centers of Influance subform].Form!First Is Not Null And Forms![Client Maintenance Center Search]![Centers of Influance subform].Form!Last Is Not Null Then
      Forms![Client Maintenance Center Search]![Centers of Influance subform].Form!Page4781 = RGB(0, 0, 255) 'blue
      Else
      Forms![Client Maintenance Center Search]![Centers of Influance subform].Form!Page4781 = RGB(0, 0, 0) 'black

      End If
      I get the following error: " Object required"

      Comment

      • ielamrani
        New Member
        • Feb 2007
        • 72

        #4
        sorry the complete error message is:

        Run time error '424'
        Object required

        Thanks

        Comment

        • puppydogbuddy
          Recognized Expert Top Contributor
          • May 2007
          • 1923

          #5
          Originally posted by ielamrani
          sorry the complete error message is:

          Run time error '424'
          Object required

          Thanks
          You did not me which line was highlighted, but I think it would be the line referencing the the tab page because the tab control is not part of the form/subform reference.....i t has its own reference as shown:

          Genericreferenc e>>>>TabCtl1.Pa ges.Item(0) >>item is page index
          Your reference???>>> >TabCtl4781.Pag es.Item(0) >>index for first tab page

          Comment

          • ielamrani
            New Member
            • Feb 2007
            • 72

            #6
            Yes the first line is the one highlighted. I am not following on the next lines, how do I include them in my code?

            Genericreferenc e>>>>TabCtl1.Pa ges.Item(0) >>item is page index
            Your reference???>>> >TabCtl4781.Pag es.Item(0) >>index for first tab page

            thanks

            Comment

            • puppydogbuddy
              Recognized Expert Top Contributor
              • May 2007
              • 1923

              #7
              Originally posted by ielamrani
              Yes the first line is the one highlighted. I am not following on the next lines, how do I include them in my code?
              thanks
              The first line looks ok. In order to check it out, I need to double check the following:
              Main Form Name?
              Subform Control Name?
              Source Object Name?
              Is First what is shown for the name property of the textbox?

              The tab page is referenced by tab control name and page index, so when you try to set the color of the first tab page, you should reference as:
              Page4781.Pages. Item(0).BackCol or = ..... >>>assuming that the tab control name is Page4781.

              Comment

              • puppydogbuddy
                Recognized Expert Top Contributor
                • May 2007
                • 1923

                #8
                I did some research and found out that the color properties are not available to the tab control and tabs. The good new is that you can accomplish what you want using a trick. The following link is an excellent "How To" tutorial with code examples and a downloadable working demo file based on the tutorial. Enjoy!

                Comment

                • ielamrani
                  New Member
                  • Feb 2007
                  • 72

                  #9
                  Thank you so much for all your help.

                  Comment

                  • puppydogbuddy
                    Recognized Expert Top Contributor
                    • May 2007
                    • 1923

                    #10
                    Originally posted by ielamrani
                    Thank you so much for all your help.
                    You are welcome. I'm glad I could help.

                    Comment

                    Working...