Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Continuous Forms and Conditional Formatting 1

Status
Not open for further replies.

Malc2

Programmer
Jul 24, 2010
4
US
Hi all,

I'm using Access 2003.
First, I have read many articles about using cond. formatting with continuous forms. The primary means seem to be using the Format->Conditional Formatting menu, or to create a box that will cover the background.

I'm trying to use the built-in mechanism, using an Expression to change the background color of a field if the expression is true. Here's the gist of it. I have another form (we'll call Ranking) where the user can select records. If they select those records, a unique ID is added to a global/Public string array via VBA. That form closes, and this other form (we'll call Master) opens. I want a certain field to be highlighted, if that record contains the same Unique ID. I also use a Public Function to return the array. Here's my expression:
Code:
InStr(Join(query_satExclude()),[txtControlName].[Value])>0
I have also tried:
Code:
InStr(Join(query_satExclude()),[fieldName])>0
Neither appear to work, nor anything else I've tried. I can put a "true" expression in, and that works, just to verify the rest of my expression is correct:
Code:
InStr(Join(query_satExclude()),"uniqueID")>0

This shouldn't be that hard...I feel like I'm missing something simple. Thanks in Advance for any help :)

Malcolm




 

For starters [blue]Join[/blue] is a [blue]reserved word[/blue] (kb248738). Don't use it!

Post your function [blue]query_satExclude()[/blue] as well as the function [blue]Join()[/blue].

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Join() is a VBA function. As is InStr().
I can see Join being a reserved word for SQL aspects. I wrote a wrapper for it, but it doesn't seem to work either.

Code:
Public satExclude() as String

Public Function query_satExclude() As Variant
    query_satExclude = satExclude
End Function

Public Function myJoin(arr As Variant) As String
    If Not IsArray(arr) Then
        myJoin = ""
    Else
        myJoin = Join(arr)
    End If
End Function

With the new conditional formatting as:
Code:
InStr(myJoin(query_satExclude()),[txtEID].[Value])>0

Can't reference a Public/Global variable directly from Conditional Formatting, hence the query function.

Thanks for looking at this.
 
Oh. And just to also clarify, using Join() directly in the conditional worked ok. I could hard code a value in, like:
Code:
InStr(Join(query_satExclude()),"123456")>0
and that worked. same with my new function, myJoin(). It's something with the way it references the record field. I'm not doing that part right or something...
 
Malc2 . . .

Ok, lets try wrapping the whole thing. In a module in the modules window, copy/paste the following function:
Code:
[blue]Public Function Ans(Dat As String) As Boolean
   
   If InStr(Join(query_satExclude()), Dat) > 0 Then Ans = True

End Function[/blue]
The above changes your format expression to:
Code:
[blue]Ans([txtControlName]) = True[/blue]
[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Thanks for the input Aceman. Worked like a charm.

Thanks,
Malcolm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top