• Different color text on report items? (A97)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Different color text on report items? (A97)

    Author
    Topic
    #409919

    I am working on an inventory program for some friends.

    They will be using this program to also print labels for the boxes their inventory is in.

    Each item on the label needs to be a different color, but the color is specific to the item on the label.

    I can’t say that Field X is always Blue and Field Y is always Black. X can be any color depending on what is ordered.

    I have the colors stored as text along with the inventory item descritptions (vbCyan, vbBlack, etc…) in a table.

    How do I tell the report to use that color?

    Thanks!

    Viewing 1 reply thread
    Author
    Replies
    • #877175

      I got it…

      I had tried:

      Private Sub Detail_Format(Cancel as Integer, FormatCount as Integer)
           me.txtField1.ForeColor = [Color]
      End Sub
      

      But I had to go with this:

      Private Sub Detail_Format(Cancel as Integer, FormatCount as Integer)
          Select Case [Color]
              Case "vbCyan"
                   me.txtField1.ForeColor = vbCyan
              Case "vbRed"
                   me.txtField1.ForeColor = vbRed
              End Select
      End Sub
      
      • #877181

        You can use the first syntax but then you have to store the numbers in the table instead of the vb constant.

        • #877183

          I had tried the Hex value, but I got a Type Mismatch error…

          • #877185

            I mean in the table itself.
            Where you have vbcayn, store 16776960
            for vbred, store 255
            for vbblack, store 0
            for vblue, store 16711680
            ect…
            Use an update query to change the constants to numbers and after that change the type of the field to numeric.
            This is theoretical as there is nothing wrong with the code you use now. It is only a little longer to write.

          • #877186

            I mean in the table itself.
            Where you have vbcayn, store 16776960
            for vbred, store 255
            for vbblack, store 0
            for vblue, store 16711680
            ect…
            Use an update query to change the constants to numbers and after that change the type of the field to numeric.
            This is theoretical as there is nothing wrong with the code you use now. It is only a little longer to write.

        • #877184

          I had tried the Hex value, but I got a Type Mismatch error…

      • #877182

        You can use the first syntax but then you have to store the numbers in the table instead of the vb constant.

    • #877176

      I got it…

      I had tried:

      Private Sub Detail_Format(Cancel as Integer, FormatCount as Integer)
           me.txtField1.ForeColor = [Color]
      End Sub
      

      But I had to go with this:

      Private Sub Detail_Format(Cancel as Integer, FormatCount as Integer)
          Select Case [Color]
              Case "vbCyan"
                   me.txtField1.ForeColor = vbCyan
              Case "vbRed"
                   me.txtField1.ForeColor = vbRed
              End Select
      End Sub
      
    Viewing 1 reply thread
    Reply To: Different color text on report items? (A97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: