Formatting a textbox with string from a VBA Function

J

James Minns

Hi to all in the group!

I have a form to view data from a query; one item in a text box is a numeric
value.
I wish to format this numeric value in a special way, lets say, writing the
value as text like this

The number
2
should be formatted like this:
"2 (two)"

I have a VBA function which takes a numeric value and returns a formatted
string, but I can't see how to use it in a form.
Something like ControlSource=SpecialFormat([TheNumber])
but that does not work. SpecialFormat is the function name, TheNumber is the
field name.
If i use ControlSource=SpecialFormat(2)
then the textbox shows the correct answer "2 - (two)". It is objecting to
the field name in the expression

Any ideas?
Thanks, James
 
J

James Minns

James Minns said:
Hi to all in the group!

I have a form to view data from a query; one item in a text box is a
numeric value.
I wish to format this numeric value in a special way, lets say, writing
the value as text like this

Something like ControlSource=SpecialFormat([TheNumber])
but that does not work. SpecialFormat is the function name, TheNumber is
the field name.

Found my mistake - Access had named the textbox "TheNumber" which was used
in the function call.
Circular reference... Renamed the box to avoid problem!

James
 
G

Guest

hi,
wild guess
try ControlSource=SpecialFormat(Me.[TheNumber])
or ControlSource=SpecialFormat(Me.TheNumber)
you might also try an exclamation point instead of a dot.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top