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 / Forms / March 2007

Tip: Looking for answers? Try searching our database.

Restricted text

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JayTee - 14 Mar 2007 12:02 GMT
Hi all,
Can someone please tell me the code to ensure a user enters only the
following combination of text and Numbers. (i.e. JT0982) I have a Access
front linked to an SQL back end.
I know there is a mask but this won't help me because of the back end being
SQL and I don't know how to set the required text combination in SQL so I
thought I would see if I can obtain a bit of code to use on a text boxes
after update event.
The bottom line is, if some enters anything else other then the combination
of 2 letters followed by 4 numbers with no spaces a message will pop up
saying "Invalid Sign on" All signons on this database cosist of the above
combination.
Thanks in advance for anyone that may be able to assist me.

J
missinglinq - 14 Mar 2007 13:53 GMT
Something like this should do it, replacing YourControl with the actual name
of your control:

Private Sub YourControl_BeforeUpdate(Cancel As Integer)
Dim I As Integer
Dim Hits As Integer
Hits = 0

'This insures that string is AA1234 format

For I = 1 To 2
 If IsNumeric(Mid(Me.YourControl, I, 1)) Then
   Hits = Hits + 1
 End If
Next I

For I = 3 To 6
 If Not IsNumeric(Mid(Me.YourControl, I, 1)) Then
   Hits = Hits + 1
 End If
Next I

If Hits > 0 Then
  MsgBox "This field must be in the format AA1234 with no spaces!"
  Cancel = True
  Me.YourControl.SelStart = 0
  Me.YourControl.SelLength = Len(Me.YourControl)
End If
End Sub

>Hi all,
>Can someone please tell me the code to ensure a user enters only the
[quoted text clipped - 11 lines]
>
>J
 
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.