Solved

Textbox background color (report)

Posted on 2004-10-28
329 Views
Last Modified: 2006-11-17
Hi experts !

I'd like to know how I could change, with Access97, the background of a textbox placed on a report. In fact, it'd be conditionnal, like if text1 <> text2, then text2.background = new color.

Thanks, code needed !
0
Question by:rouxjean
    10 Comments
     
    LVL 4

    Expert Comment

    by:CrossWired
       If MsgBox("Yes or No", vbYesNo) = vbYes Then
            Me.DESCR.BackColor = 0
            Me.DESCR.BackStyle = 1
        End If


    Put this on the OnOpen event of your report, and of course set the condition to whatever you need

    0
     
    LVL 4

    Expert Comment

    by:CrossWired
    what do you mena by text1 <> text2 what will you be comparing?
    0
     
    LVL 34

    Expert Comment

    by:flavo
    try (not sure never done it)

    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
      If Me.txt1 <> Me.txt2 Then
        Me.txt1.BackColor = vbBlue
      Else
        Me.txt1.BackColor = vbRed
      End If
    End Sub
    0
     

    Author Comment

    by:rouxjean
    CrossWired : The report is based on a table, so for each record, if the text1 content is different than the text's 2 contents...I need to change the color to text2. I don't have the backcolor propertie...
    0
     
    LVL 34

    Expert Comment

    by:flavo
    rouxjean,

    This is one of those "tricky" ones..

    The text box control does have the BackColor property, just that the intelisense doesnt show it, so you cant use the list that pops up, youll have to type the whole word by hand.

    Good Luck!

    Dave
    0
     

    Author Comment

    by:rouxjean
    tried: Me.Texte42.BackColor = vbRed on the form onload event...its still white ! I'd also like to use RGB if possible...
    0
     
    LVL 4

    Assisted Solution

    by:CrossWired
    be sure to change the style to solid vice Transparent
    0
     
    LVL 34

    Accepted Solution

    by:
    report or form??

    if its a report you need to use Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

    vbBlue is a constant provide by access (actually = to 16711680)

    To use RGB use

    Me.Texte42.BackColor = RGB(red, green, blue)

    replace red, green and blue above for your values (must be between 0-255)


    Dave
    0
     

    Author Comment

    by:rouxjean
    Last thing...maybe off-topic but i can't use Me. because it can refer to query expressions of form controls. How can I ensure it works ?
    Thanks !
    0
     
    LVL 34

    Expert Comment

    by:flavo
    is it a form or report..

    If its a form you should be using Form_Current(), report use Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

    not sure what you are asking

    CrossWired,

    Ill leave this up too you, its getting WAY to late (1:15AM, need to get up in 4:30 hours)

    Later!

    Dave
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
    I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
    In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

    877 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

    20 Experts available now in Live!

    Get 1:1 Help Now