Field value formating not showing on form (1 Viewer)

DavidCantor

Registered User.
Local time
Today, 06:42
Joined
Oct 4, 2012
Messages
66
I have an ID field (Text Data Type) which has an input mask [00\-00\-0000;_ ]and a format [00-00-0000] but when I open the form the ID is displayed without the formatting. The formatting is applied only when I click the ID field on the form, how can i change this and set the formatting on the ID without clicking on it on the form?
 

Wayne

Crazy Canuck
Local time
Today, 09:42
Joined
Nov 4, 2012
Messages
176
Try putting this at the end of your code:
00\-00\-0000;0;_
This tells Access to store the literal (formatted) value in the field. Should work.
 

DavidCantor

Registered User.
Local time
Today, 06:42
Joined
Oct 4, 2012
Messages
66
when you say at the end of my code you mean like this? Forms!frmProductIcon2!LblpID.Caption 00\-00\-0000;_?

That doesn't work
 

Wayne

Crazy Canuck
Local time
Today, 09:42
Joined
Nov 4, 2012
Messages
176
Where did you define your input mask? If this is an input mask from the definition of the underlying table, your form should have picked it up when you created the form. Check the properties window for that field in Design View under the "Data" tab. See if it carried over to the Input Mask line for that field on the form. If not, you can fix this using VBA.

You should put this code in the BeforeUpdate event of that field:

Me.YourFieldName.InputMask = "00\-00\-0000;0;_ "

The last zero between the semi-colons at the end tells Access to store the literal (formatted) value in that field.

In future data entry, your fields will maintain their formatting exactly as you entered it.

For the existing records, put the same code in the form's OnOpen event, and that should clear it up. That will set the formatting up every time the form is opened.
 

DavidCantor

Registered User.
Local time
Today, 06:42
Joined
Oct 4, 2012
Messages
66
Where did you define your input mask? If this is an input mask from the definition of the underlying table, your form should have picked it up when you created the form. Check the properties window for that field in Design View under the "Data" tab. See if it carried over to the Input Mask line for that field on the form. If not, you can fix this using VBA.

You should put this code in the BeforeUpdate event of that field:

Me.YourFieldName.InputMask = "00\-00\-0000;0;_ "

The last zero between the semi-colons at the end tells Access to store the literal (formatted) value in that field.

In future data entry, your fields will maintain their formatting exactly as you entered it.

For the existing records, put the same code in the form's OnOpen event, and that should clear it up. That will set the formatting up every time the form is opened.
I created a label and the caption is the ID but the caption doesnot show the mask it just shows the numbers without the formatting
 

Wayne

Crazy Canuck
Local time
Today, 09:42
Joined
Nov 4, 2012
Messages
176
I'm not sure why you would store data in either a label or a caption. Is it a unique caption / label that applies to all records on the form, or is the ID number just a record number, or is it a unique part number, or something like that? If it is data, it should be stored in a field, so it can be manipulated any way you need it.

Can you send me a copy of what you're doing, and I can probably work out a solution for you.
 

Users who are viewing this thread

Top Bottom