Coditional Formatting in Form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tymperance
    New Member
    • Aug 2006
    • 33

    Coditional Formatting in Form

    I have a datasheet form attached to a query that is searching for Expiration dates in four fields. The user inputs a date (query has [Enter Expiration Date] on different rows for each field so the user only inputs one date). On the form I need to be able to say if the field date is > Date() and <= the user inputted date return a specific color. My issue is writing the expression for the user inputed date since it is not a field stored to my form. Is this possible?

    Thanks,
  • comteck
    New Member
    • Jun 2006
    • 179

    #2
    Where is the "field date" you are referring to? Is it tied to the form as a textbox?

    comteck

    Comment

    • MMcCarthy
      Recognized Expert MVP
      • Aug 2006
      • 14387

      #3
      Because you have the user entering this date based on conditional formatting in the query it is not being stored as a separate entity.

      The only thing I can suggest is that you make the datasheet a subform of another form on which you have the user enter a date into an unbound field. you can then set the value of this field as the conditional criteria instead of the Entry Prompts.

      You can then reference this value as it is separately stored.

      Originally posted by tymperance
      I have a datasheet form attached to a query that is searching for Expiration dates in four fields. The user inputs a date (query has [Enter Expiration Date] on different rows for each field so the user only inputs one date). On the form I need to be able to say if the field date is > Date() and <= the user inputted date return a specific color. My issue is writing the expression for the user inputed date since it is not a field stored to my form. Is this possible?

      Thanks,

      Comment

      • tymperance
        New Member
        • Aug 2006
        • 33

        #4
        Originally posted by mmccarthy
        Because you have the user entering this date based on conditional formatting in the query it is not being stored as a separate entity.

        The only thing I can suggest is that you make the datasheet a subform of another form on which you have the user enter a date into an unbound field. you can then set the value of this field as the conditional criteria instead of the Entry Prompts.

        You can then reference this value as it is separately stored.
        Thank You!

        I did that and I think it will work. I'm guessing I need an Update After event or something like that to have the subform update once the date is entered. I'm new at this and have no idea how to begin. Should I use the property After Update [Event Procedure] or do I need to write it in VBA? How do I do either?

        Thanks!

        Comment

        • tymperance
          New Member
          • Aug 2006
          • 33

          #5
          Originally posted by comteck
          Where is the "field date" you are referring to? Is it tied to the form as a textbox?

          comteck
          No, it wasn't. It was an EXP1 field added to the underlying table. Since then I have added a form to catpure the date and then made my original form a subform. Only problem is I can't the the subform to update when the new form is changed.

          Thanks!

          Comment

          • MMcCarthy
            Recognized Expert MVP
            • Aug 2006
            • 14387

            #6
            Firstly, have you set the RecordSource of the new form to the table or query containing your Exp1 date field.

            If so, then make sure the Exp1 field is on the form as well as the user input field.

            Then in the After Update event of the user input field put a code something like this:

            Private Sub UserInputDate_A fterUpdate()

            If Me.Exp1.Value > Date And Me.Exp1.Value <= Me.UserInputDat e.Value Then

            Me.Exp1.BackCol or = 16711680 ' Blue

            End If

            End Sub

            Originally posted by tymperance
            Thank You!

            I did that and I think it will work. I'm guessing I need an Update After event or something like that to have the subform update once the date is entered. I'm new at this and have no idea how to begin. Should I use the property After Update [Event Procedure] or do I need to write it in VBA? How do I do either?

            Thanks!

            Comment

            • comteck
              New Member
              • Jun 2006
              • 179

              #7
              Are you sure it's "Cod-itional" formatting, and not "Con-ditional"? Sounds fishy to me.

              comteck

              Comment

              • tymperance
                New Member
                • Aug 2006
                • 33

                #8
                HeHeHe. Oops!

                Comment

                • tymperance
                  New Member
                  • Aug 2006
                  • 33

                  #9
                  Thanks so much for the reply!

                  Since I am using a form to capture the EXP1 (expiration date) I am no longer having the pop-up for the user to input the date. The user will input directly to EXP1. This is stored on form Expiration Date Field. The subform on this is Expired Numbers and both forms RecordSource is Expired Numbers query. Now that I have changed this I need to write it so that IF field LEXP is > DATE() and <= EXP1 then BackColor is blue.

                  I tried making modifications to what you gave me to make this work and it still is not. Would I store this on EXP1's or on LEXP's AfterUpdate()?

                  Comment

                  • MMcCarthy
                    Recognized Expert MVP
                    • Aug 2006
                    • 14387

                    #10
                    Since the user is entering EXP1 that is the field being updated. Therefore the After Update event should be on EXP1 as follows:

                    Private Sub EXP1_AfterUpdat e()

                    If Me.LEXP.Value > Date And Me.LEXP.Value <= Me.EXP1.Value Then
                    Me.LEXP.BackCol or = 16711680 ' Blue
                    End If

                    End Sub


                    Originally posted by tymperance
                    Thanks so much for the reply!

                    Since I am using a form to capture the EXP1 (expiration date) I am no longer having the pop-up for the user to input the date. The user will input directly to EXP1. This is stored on form Expiration Date Field. The subform on this is Expired Numbers and both forms RecordSource is Expired Numbers query. Now that I have changed this I need to write it so that IF field LEXP is > DATE() and <= EXP1 then BackColor is blue.

                    I tried making modifications to what you gave me to make this work and it still is not. Would I store this on EXP1's or on LEXP's AfterUpdate()?

                    Comment

                    • tymperance
                      New Member
                      • Aug 2006
                      • 33

                      #11
                      I get a Compile Error: Method or data member not found when updating the EXP1 field. The .BackColor is bieng highlighted.

                      Comment

                      • MMcCarthy
                        Recognized Expert MVP
                        • Aug 2006
                        • 14387

                        #12
                        Is LEXP a textbox or some other type of control.

                        When you type

                        Me.LEXP.

                        do you get a dropdown list including BackColor?



                        Originally posted by tymperance
                        I get a Compile Error: Method or data member not found when updating the EXP1 field. The .BackColor is bieng highlighted.

                        Comment

                        • tymperance
                          New Member
                          • Aug 2006
                          • 33

                          #13
                          Yes it is a text box and the dropdown list only has Value on it. Is that a problem?

                          Originally posted by mmccarthy
                          Is LEXP a textbox or some other type of control.

                          When you type

                          Me.LEXP.

                          do you get a dropdown list including BackColor?

                          Comment

                          • MMcCarthy
                            Recognized Expert MVP
                            • Aug 2006
                            • 14387

                            #14
                            It sounds like you're missing a library reference. Go to Tools - References and let me know what libraries are ticked there.



                            Originally posted by tymperance
                            Yes it is a text box and the dropdown list only has Value on it. Is that a problem?

                            Comment

                            • tymperance
                              New Member
                              • Aug 2006
                              • 33

                              #15
                              Visual Basic For Applications
                              Microsoft Access 10.0 Object Library
                              Microsoft DAO 3.6 Object Library
                              OLE Automation
                              Microsoft Visual Basic for Applications Extensibility 5.3 Microsoft Offixe XP Web Components

                              That's it.

                              Originally posted by mmccarthy
                              It sounds like you're missing a library reference. Go to Tools - References and let me know what libraries are ticked there.

                              Comment

                              Working...