Calling function in conditional formatting expression

  • Thread starter Thread starter Dale Fye
  • Start date Start date
D

Dale Fye

Does anyone know how or if you can call a function and pass it a control in a
conditional formatting expression of a textbox on a continuous form?

I've done some font size analysis and developed a function fnDoesItFit(ctrl)
which accepts the name of a textbox control. It then does a quick assessment
of whether the text in the textbox will fit within the area of the textbox
and returns a boolean value. I've implemented this in a single forms current
event and it works great to allow me to change the background color and
scrollbar property of the control based on the amount of text.

However, what I really want to do is use this on a continuous form, and
rather than putting it in the current event (which would affect the textbox
in each of the records), I want to put the function call in the Conditional
Formatting of the textbox. I know I won't be able to affect the scrollbar
property, but if I can at least highlight those records where the text
exceeds the size of the textbox, it will make viewing the data easier.

I've tried setting the condition to "Expression Is", and then entering:

fnDoesItFit(me.txt_TextString) = 0

In the expression, but this is not working.

Thanks in advance.
 
Dale,

I have never tried to use a UDF in conditional formatting, but a couple of
things jump out at me. Based on other rules in Access, you may need to put
an = sign in front of the function name, and I think, if it will work at all,
you would need to qualify the form name rather than using Me. Try:

=fnDoesItFit(Forms!FormName!txt_TextString) = 0

BTW, if you get it working, I would appreciate a copy of the function. It
sounds like a useful and certainly interesting function.

Thanks,
 
Dave,

That did it. It did not require the equal sign, but worked with a complete
reference to the forms!formname.controlname

fnDoesItFit(Forms!FormName.ControlName)=0

Give me a chance to clean it up a bit, and I'll send it to you.

Dale
 
Glad it worked!
We both learned something today.
I will be looking forward to seeing the code. Doesn't have to be clean. I
have a box of Sanitizing Code Wipes at my desk. Believe me, I go through a
lot of them <g>
 
How would you like me to get you the file?

--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.
 
I wasn't thinking file, I was assuming you could copy/paste the function in a
reply. If there is more I need to have, let me know and we can work
something out. I am reluctant to put my email address where it can be seen in
public.
 
The function itself is simple, but it relies on a datafile that contains the
critical values for each font and font size.

I don't blame you about your email concerns. I'll post a spam resistant
email address to my user profile. If you can get to that, on the microsoft
communities website, then email me and I'll send you the file.

Dale
 
Thanks, Dale. I sent the email.
Looking forward to seeing this. Based on your description, you are
venturing into Lebans territory <g>
 
The Conditional Formatting sample on my site shows how to handle the issues
describe3d by the OP.
http://www.lebans.com/conditionalformatting.htm
A2K or Higher Only!

New Feb 08,2002. Added support for Datasheet view and SubForms.

A2KConditionalFormatting.zip is a sample MDB demonstrating how to
programmatically setup Conditional Formatting to simulate:

1) Highlighting of the Current Row for a Form in Continuous or Datasheet
View

2) Highlighting of Alternate Rows for a Form in Continuous or Datasheet View

Version 2.7

Added sample demonstrating how to achieve a background Hover/Highlighting of
rows for a form in Continuous view.

Version 2.3

Added sample demonstrating how to achieve pseudo enable/disable of an
unbound control on a form in Continuous View.

Version 1.9

Added sample form to show how to apply conditional formatting to based on a
Boolean(Yes/No) field.
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Back
Top