Input Mask Question

jibb

Registered User.
Local time
Today, 08:40
Joined
Dec 1, 2011
Messages
93
I have a form which needs to have the location of stock entered into it. It should look like this when its done L-06-B-R - can i format it so that you only have to enter a single figure when it is below 10 and it puts a 0 in front of it eg. enter l6br and it reads L-06-B-R. The current mask is >L\-00\->L\->L .

Many Thanks
 
Jibb,
Don't think the input mask is the way to go. Using #0, allows numbers less than ten, but it puts a space in there and you want a zero. You are trying to mix a number with text and that only works if the two are in separate fields and you concatenate them afterwards.

But there is a way to do this. You could use the afterupdate event on your form to grab the l6br and format it as needed. Try something like this:

In the form you are using, copy the code below and save it.

Function CodeMe(LC As String)
Dim SN As String 'String number
SN = Trim(Mid(LC, 2, Len(LC) - 3))
If Len(SN) < 2 Then
SN = "0" & SN
End If
CodeMe = UCase(Left(LC, 1)) & SN & UCase(Mid([LC], Len([LC]) - 1, 1)) & UCase(Right(LC, 1))
End Function

In the After_Update event of this text box called, say, "Location" put this:
me.location.value = CodeMe(me.location.value)

I did not put any error trappings in here. I am relying on the format you gave to stay common. Meaning, one letter, one to many numbers, and two more letters. Any deviations and you will have to edit the code. Hope this helps
Privateer
 

Users who are viewing this thread

Back
Top Bottom