Results 1 to 7 of 7
  1. #1
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Conditional Formatting (Access 2000 - SR1)

    Access 2000 has a nice little feature called Conditional Formatting which allows you to change the appearance of a field depending upon one of three conditions:
    Field Value is, Expression is or Field has focus.
    Here is the scenario: I have a continuous form which has three fields, Name , Phone Number and Fax Number:
    What I've been attempting to do is create an "Expression is" in the Phone Number and Fax Number fields which will change their colours if Name has "GotFocus", ie. Someone has put their sticky little cursor on it.

    I've tried: Iif(Has GotFocus([Name]),Visible=True,Visible=False)
    and several variations, give or take the odd paranthesis, on the same theme. The VBA gods just laughed at me. I would appreciate any suggestions. Thanks in advance.
    Cheers,
    Andy

  2. #2
    Star Lounger
    Join Date
    Nov 2001
    Location
    Illinois, USA
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Conditional Formatting (Access 2000 - SR1)

    Could you put the code in the GotFocus event of the Name field instead of in the Phone Number and Fax Number fields? PhoneNumber.visible=true. Then in the LostFocus event code for Name: PhoneNumber.visible=false

  3. #3
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Wellington, New Zealand
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Conditional Formatting (Access 2000 - SR1)

    The problem that you have with your expression is that you have not used the correct syntax.

    The first thing that you should probably do, is display the properties of the field that you wish to have the conditional formatting for. Then on then Event tab, double click next to the Got Focus event and then click the ellipsis button (the one to the right with three dots (...)). This will take you to the Visual Basic window for the Got Focus event of the control.

    It will probably look something like this

    <font face="Georgia">Private Sub Name_GotFocus()

    End Sub</font face=georgia>

    Between these lines you will want to put your values that change the background colours of the phonenumber and fax number controls

    This would look something like this:

    <font face="Georgia">PhoneNumber.BackColor = 255
    FaxNumber.BackColor = 255
    </font face=georgia>

    So the complete part of this will look like this

    <font face="Georgia">Private Sub Name_GotFocus()
    PhoneNumber.BackColor = 255
    FaxNumber.BackColor = 255
    End Sub</font face=georgia>

    So what this would do, is that when the Name field gets the focus, the PhoneNumber and FaxNumber fields change their color to red. I'm not entirely sure why you are wanting to do this, but hey this should work if that is what you are trying to do.

    One last thing, as that I guess that you wish for these fields to return to their orginal colour when the Name control looses the focus again. So, you need to follow a similar proceedure for the Name control for it's Lost Focus event.

    The LostFocus event for the Name control would look similar but have the background colour of the phonenumber and faxnumber controls put back to whatever colour they were orginially.

    Hope that this spreads some light on your problem.

  4. #4
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Conditional Formatting (Access 2000 - SR1)

    Dottie:
    Thanks for your response. Your solution would be bang on if I only wanted the fields to disappear. I'm afraid my example was ambiguously worded. Check out Jayden's answer, because, in spite of my efforts to confuse, he understood what I was attempting to do and came up with the answer. Thanks again for your suggestion.
    Cheers,
    Andy

  5. #5
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Conditional Formatting (Access 2000 - SR1)

    Jayden:
    Thanks for your solution which did answer my problem in spite of my efforts to confuse. I appreciate you taking the time to help out. Hopefully someone will ask an easy question that I can answer before the knowledgeable ones. <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Cheers,
    Andy

  6. #6
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Wellington, New Zealand
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Conditional Formatting (Access 2000 - SR1)

    No problem, it's always fun <img src=/S/grin.gif border=0 alt=grin width=15 height=15> to help others out. I only wish that I had a resource like this when I was starting to learn Access, it would have reduced many hours trying to decipher the MS Help files.

  7. #7
    Star Lounger
    Join Date
    Nov 2001
    Location
    Illinois, USA
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Conditional Formatting (Access 2000 - SR1)

    You're welcome! I am glad that Jayden's solution was exactly what you needed. I have just recently discovered The Lounge and also find it to be an amazing resource! I am learning so much from reading people's solutions. Good luck with your project!

Posting Permissions

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