Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 406
  • Last Modified:

Conditional formatting access 2007

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
Mike Eghtebas
Asked:
Mike Eghtebas
  • 3
  • 2
1 Solution
 
Rey Obrero (Capricorn1)Commented:
change this line

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


with


fnCurrentRecord = IIF(Formas!fAction!txtactionId = lngId, True, False)
0
 
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
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
 
mbizupCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
Thank you.
0
 
mbizupCommented:
Glad to help, Mike.  Good to see you around.
0
 
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
Thanks. I was luck my question got your attention.
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now