Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / March 2007

Tip: Looking for answers? Try searching our database.

Making mask in a table

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Una Tutta - 23 Mar 2007 10:50 GMT
I want to make a mask in a table.  It should be min 4 numbers in txt format
Eks. 1 should be 0001  not 1, 123 shoul be 0123.
Jerry Whittle - 23 Mar 2007 14:34 GMT
Let's say that the field size is 10. The input mask would be:

 0000######

That makes the first four digits mandatory and the last 6 digits optional.
If any of the last 6 aren't entered, they are NOT stored as spaces.
Signature

Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

> I want to make a mask in a table.  It should be min 4 numbers in txt format
> Eks. 1 should be 0001  not 1, 123 shoul be 0123.
Joseph Meehan - 23 Mar 2007 14:38 GMT
> I want to make a mask in a table.  It should be min 4 numbers in txt
> format Eks. 1 should be 0001  not 1, 123 shoul be 0123.

   Are you using a text field or a number field.  Tables do not same
numbers with leading zeros.  You can display numbers with leading zeros as a
format in queries(?), reports and forms.  If you choose text then you will
not be able to do math computations on the text.

Signature

Joseph Meehan

Dia 's Muire duit

Wayne-I-M - 23 Mar 2007 14:45 GMT
Hi Una

I would not bother with a mask.  -  Up to you though.

If you are using a form to update the record I would use the AfterUpdate
event of the control to alter the data.  Something like this

Private Sub FieldName_AfterUpdate()
If Len(Me.FieldName) < 5 Then
Me!FieldName = Right("0000" & Me!FieldName, 4)
End If
End Sub

Change "FieldName" to what it is on the form and it should be OK.

If the data is "always" 4 digits you could set this as a variable and use
something like this

Private Sub FieldName_AfterUpdate()
Dim SomeName As Long
If SomeName = Len("FieldName") < 4 Then
Me!FieldName = Right("0000" & Me!FieldName, 4)
End If
End Sub

Change FieldName again and I wouldn't use "SomeName" so change this as well.
Note this will of course trim the data to 4  so don't use if this is not
what you want (not really sure from your post).  Or include an "else" to the
above to show longer strings.

Hope this helps

Signature

Wayne
Manchester, England.

> I want to make a mask in a table.  It should be min 4 numbers in txt format
> Eks. 1 should be 0001  not 1, 123 shoul be 0123.
Wayne-I-M - 23 Mar 2007 14:49 GMT
ooops

If SomeName = Len("FieldName") < 4 Then

Should be

If SomeName = Len("FieldName") < 5 Then

Signature

Wayne
Manchester, England.

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.