Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: Color Coding

  1. #1
    Join Date
    Mar 2004
    Posts
    83

    Unanswered: Color Coding

    I would like to have a raised Option box on my form that when I click it, it cycles through 3 colors. I just made an If/Else to loop through them, that works fine. What I am having problems doing is tying the color code to the DB, I have no idea what to do.

    So you know how when you switch records, the data in the textboxes changes to relfect whats stored in that field, thats what I need to do with colors. For example record 1 is assigned 16758883 (for blue), and record 2 is assigned 65280.

    Any suggestions?

  2. #2
    Join Date
    Aug 2002
    Location
    Northampton, England
    Posts
    266
    have a look at BackColor in the help files.

  3. #3
    Join Date
    Mar 2004
    Posts
    83
    I know how to change the color, that part is working...it's the number saving to the DB AFTER it's changed that I'm having problems with.

  4. #4
    Join Date
    Feb 2004
    Location
    Swindon, UK
    Posts
    86
    what code are you using?

    could you not add another field to your table called colour ID, and within the code assign a specific number to each colour, then have code so that when it goes to a new record it check the id then changes the colour to the correct colour. if that makes any sense

  5. #5
    Join Date
    Mar 2004
    Posts
    83
    <CODE>
    If lblColorCode.BackColor = 12632256 Then
    lblColorCode.BackColor = 16758883
    ElseIf lblColorCode.BackColor = 16758883 Then
    lblColorCode.BackColor = 65280
    ElseIf lblColorCode.BackColor = 65280 Then
    lblColorCode.BackColor = 16775416
    ElseIf lblColorCode.BackColor = 16775416 Then
    lblColorCode.BackColor = 16758883
    End If
    </CODE>

    Good idea, I made a new table that is joined to the main, it stores all the color codes and a text name. So how do I get that to translate into the data being saved? I'm assuming there's some code that would go before each ElseIf, I just have no idea what it would be.

  6. #6
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    just dump the number into a variable and stick it in your table.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  7. #7
    Join Date
    Mar 2004
    Posts
    83
    Ok, so [ColorID] = Value works.

    How exactly do I got about Loading the saved color on a record change?

  8. #8
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    In the On Print section of the detail section, you could set:

    me.detail.backcolor = [ColorID]

    IN addition, I would advise taking a slightly different route and store just an integer as a color code, then parse those IN the vb code, it will be much easier to deal with.

    Then you could stuff those color codes into human-readable numeric variables.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  9. #9
    Join Date
    Mar 2004
    Posts
    83
    I've never used OnPrint before...is it like a draw event when the window get painted?

    Also, since it not on the dropdowns, I just typed in

    Private Sub Detail_OnPrint()
    MsgBox "Test"
    End Sub

    Nothing happened, but am I on the right track?

  10. #10
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Well piss..

    I assumed forms shared that event with reports.

    Apparantly they do not.

    I'll do a little digging, now I've got to figure it out or it's going to eat at me.

    rawr.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  11. #11
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    After some experimenting, it seems the problem is more complex then even originally thought. Access views the ENTIRE detail section as one object. Therefore you cannot address a single row, like you can do with reports. Setting me.detail.backcolor = anything is going to assign the ENTIRE detail section to that color. Likewise if you attempt to address only the text fields. I am of course assuming that you are using continious forms here as well. If not, then these drawbacks aren't going to effect you and you can use the forms OnCurrent event.

    PUtting my feelers out and digging around, I'm thinking this is going to be WAY more work then it's worth, requiring some SERIOUS hacking of the underlying access foundation.
    Last edited by Teddy; 06-24-04 at 14:39.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  12. #12
    Join Date
    Mar 2004
    Posts
    83
    Well, there goes that idea...

    ...Is there no record change event that gets fired when you click the buttons?

  13. #13
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Sure there is.

    I guess I should have asked, are you using single or continious forms? If it's single, then there's hope yet.

    Continious, it doesn't matter when the action is fired, because the every single record inherits it's background from the detail section as a whole.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  14. #14
    Join Date
    Mar 2004
    Posts
    83
    Single, flat sheet witht he 50 or so fields all mashed together

  15. #15
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Awesome, the forms OnCurrent event should do the trick for you then.

    Remember to set the background for the fields to transparent.

    Unless of course, you WANT to write code for each individual txtbox.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •