Dependent Formatting (Text or Numbers

F

F1stman

Hello All,
I am attempting create formatting for an object based upon the value
displayed. If the value is six numbers entered without spaces (Ex. 123456),
then the formatting should be "##-##-##" (Ex. 12-34-56). Otherwise, the
object must allow regular text. I have tried several different methods but
with no luck. Below is my most recent attempt. I tried inserting it into the
"lost focus", "on change", and "after update actions". Many thanks in advance
for helping clear up a headache.

If Me.AccountCode1 Like "######" Then
Me.AccountCode1.Format = "##-##-##"
End If

Adam L Kemp
 
K

KARL DEWEY

To the best of my knowledge (limit it is) you only get one format.

You could do some fancy IIF statements.
 
M

Marshall Barton

F1stman said:
I am attempting create formatting for an object based upon the value
displayed. If the value is six numbers entered without spaces (Ex. 123456),
then the formatting should be "##-##-##" (Ex. 12-34-56). Otherwise, the
object must allow regular text. I have tried several different methods but
with no luck. Below is my most recent attempt. I tried inserting it into the
"lost focus", "on change", and "after update actions". Many thanks in advance
for helping clear up a headache.

If Me.AccountCode1 Like "######" Then
Me.AccountCode1.Format = "##-##-##"
End If


That should work fine for a form in Single view. Be sure to
execute that code from both the AccountCode1 text box's
AfterUpdate and the form's Current events.
 

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