Solved

Conditional formatting  access 2007

Posted on 2013-11-30
6
400 Views
Last Modified: 2013-11-30
for a text box in a continuous form, I have:

Expression Is:   fnCurrentRecord([actionId]

And applied red font formatting.  In the form header area, I have txtactionId. Both, txtactionId and actionId, are bound to fields actionId. The display values as expected. The box txtactionId displays actionId of the record I click on.

In a module, I have:

Public Function fnCurrentRecord(lngId As Long) As Boolean

      fnCurrentRecord = IFF(Formas!fAction!txtactionId = lngId, True, False)

     Debug.Print lngId & ", " & Formas!fAction!txtactionId  & ", " & fnCurrentRecord

end Function

The printout I am getting is:
484, 484, True
479, 479, True
480, 480, True

When the form first opens. When I click on the record with actionId 479, for example, I expect to get:
484, 484, False
479, 479, True  
480, 480, False

So because it returns True for all three records; consequently, this text box has red font for all three records on the form. But I am expecting only record 479 to change to red font not other two.

Question: How can I correct this problem?

Thank you.
0
Comment
Question by:Mike Eghtebas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39687009
change this line

fnCurrentRecord = IFF(Formas!fAction!txtactionId = lngId, True, False)


with


fnCurrentRecord = IIF(Formas!fAction!txtactionId = lngId, True, False)
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 39687067
my bad, I have

fnCurrentRecord = IiF(Forms!fAction!txtactionId = lngId, True, False)

on my project. I had typo in typing at EE. So, IFF() would have giving me compile error.

So, the question remains why I am not getting:

484, 484, False
479, 479, True  
480, 480, False

What can I change to format the current record only?

Thanks
0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 39687077
You've got several simple typos in that post, but I don't think this is going to work the way you are expecting it to.  Try this instead:

1.  Add a textbox (unbound), txtID to the form -- you can set its visible property to false

2. Add code to your current event:
     Me.txtID = Me!ActionID

Open in new window

    The periods and exclamation points are important in this syntax, and ActionID should be the name of the underlying field rather than the name of the textbox

3. Set your conditional formatting, Expression IS to this:

       txtID = txtActionID              (compare the bound and unbound textboxes)
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 34

Author Closing Comment

by:Mike Eghtebas
ID: 39687218
Thank you.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39687442
Glad to help, Mike.  Good to see you around.
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 39687535
Thanks. I was luck my question got your attention.
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

617 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