Solved

Conditional formatting  access 2007

Posted on 2013-11-30
6
395 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
  • 3
  • 2
6 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 39687009
change this line

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


with


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

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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 33

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 33

Author Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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 the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

930 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

13 Experts available now in Live!

Get 1:1 Help Now