Solved

Conditional formatting  access 2007

Posted on 2013-11-30
6
392 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
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 
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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

708 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

11 Experts available now in Live!

Get 1:1 Help Now