Solved

Conditional formatting  access 2007

Posted on 2013-11-30
6
396 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 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 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2016 7 33
vba sql wild card passing in code 3 21
A Function to parse a text string 4 34
Allow user to edit an outgoing email 2 23
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
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…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

813 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

10 Experts available now in Live!

Get 1:1 Help Now