Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2005
    Posts
    113

    Unanswered: Switching backgrounds?

    I need to change the background color in a form during runtime.
    Can't find the appropriate code in VBA and I'd appreciate help on the matter.

    Thanks,
    Julita

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Hi Julita

    if you want to change soemthing in a form then the best place for that code is in the forms "on current" event.

    if you want to change soemthing base on what you enter then you may also need to call the change function from the controls "on change" events.

    the skeleton for your function could be:-

    private function ufChangeFOrmColour()
    Select case <mycontrol>.value
    case <100: me.background=qbcolor(1)
    case >100 and <1000:me.background=qbcolor(10)
    case else: me.background=qbcolor(1)
    end select

    in your forms on current event place a call to your function.
    HTH

  3. #3
    Join Date
    Nov 2005
    Posts
    113
    Thank You for the fast reply. Unfortunatly I get the error msg that "background" is not a property of a form (working in Access 97). Also need to control specific color i.e. RGB-mode.

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    what you are looking for is

    me.detail.backcolor =

    izy
    currently using SS 2008R2

  5. #5
    Join Date
    Nov 2005
    Posts
    113
    Many thanks, it's working now!
    *hug* on you.

  6. #6
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    you can find the colour constant you need by setting a test form to the desired color and in the immeditate window (Ctrl-G) type
    ? forms!yourFormName.detail.backcolor

    or maybe use one of the intrinsic constants
    vbBlack, vbBlue, vbCyan, vbGreen, vbMagenta, vbRed, vbWhite, vbYellow

    also, forgot to mention:
    me.formheader.backcolor =
    me.formfooter.backcolor =
    make sure you have a form header/footer before doing that or you will error.

    izy
    currently using SS 2008R2

  7. #7
    Join Date
    Nov 2005
    Posts
    113
    Thanks again IZY!

Posting Permissions

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