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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FormatCondition

Status
Not open for further replies.

trevorwilliams2

Programmer
Mar 3, 2003
107
US
**Access 2003
I have a form that is continous.
I have a combo box named NoteAuthor (row one, not visible is contactID)


In the on Open of the form I use FormatCondition to lock the field with:

Dim ObjToChange As FormatCondition
Set ObjToChange = Me.NoteAuthor.FormatConditions.Add(acFieldValue, acNotEqual, CurUserContactID)
ObjToChange.Enabled = False

(CurUserContactID is 34349, if not = to 34349 then lock the field)

This works good.

What I would like to do:
Lock all other fields in the record (for that record) when the above condition is met for NoteAuthor.

Any suggestions?



 
Trevor,
If you use Conditional-Formatting you can flip the Enabled property for the all fields in the row based on that condition.

I don't do it in vba, just in design view so I couldn't tell you the code but if it's not needed to be changed or set each time the form is opened then it's doable just using Expression rather than Field Value--just select the entire row of fields as you set the conditional formatting.
--Jim
 
Hi jsteph, I just looked at that and see where that could work if I simply wanted to change background color, etc. for multiple controls.

The problems is the "Enabled" property (which I need) isnt available from the form, only in VBA....

 
It is available on the form as well. It is the far right button next to the font button.
 
I see it...so no use for VBA in my case.

So is it possible in the conditional formatting of, per say, my memo field to to refer to the value in another control on the form and determine the properties settings that memo field?

Or, does conditional formatting apply only to the values of the selected control?

See the attached screenshot of the Conditional Formatting of my Memo field ("TextNoteMemo"). Cant seem to get this to work.

 
Trevor,
If you select all (or multiple) controls, you have to use "Expression" and then type in the expression, ie:

[Field_name]='some value'

I use the brackets because the dialog will try to put quotes around the fieldname, which of course you don't want.
--jim
 
Trevor,
BTW...I couldn't see the screenshot, got a page not found.
But you could do, for example:
InStr(Trim([TextNoteMemo],[SomeOtherField]) >0

And if the value of another field is found in the memo field then the formatting applies.

There's really no limit--you can put a function of your making into the expression, ie:
MyFunction([TextNoteMemo]) = True

And MyFunction() can do anything it wants, including reading other tables, etc, you can pass multiple fields to the function and do whatever coding acrobatics you want. This way you can keep the expression itself clean, and do all the dirty work in the function.
--Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top