Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lazy Users

Status
Not open for further replies.

Peps

Programmer
Feb 11, 2001
140
ES
I've got a form where, in order to print a report the user has to update a field with a user name. A messgae box hits you if this is not done. The guys I'm working with are entering "." to avoid having to enter the required name. I added a routine to prevent the entering of a single dot. but now they are entering things like , . * # etc, etc. Has anyone got any suggestions on how these actions can be denied by the system. It takes hours of thinking and programming to ensure that things are done in a better way, then it takes two seconds for someone to make you feel like your time has been completly wasted.

Peps
 
If they have to enter a user name, then I would check the table where user names are stored to make sure they have entered valid information. If the username is verified then complete, if it isn't verified, don't save, return to the form and make them enter another name

leslie
 
Is the username from a list in the table? If so, offer a drop down list, or if it will always be the current user, tie it to the network login ID (various VBA code functions are available here to show how to do this).

Failing that, you can always write code to check for the entry in this field being a minimum length and only checking for alphanumeric characters in the text box.

John
 
First of all ... Why do they have to update a field with a user name? That is, what ... if anything ... do you use the name for? It seems apparent that the users aren't realizing any benefit from it is they just stick any old string into it to make the program work.

You may indeed have spent many hours coming up with this but the final test of any programming feature is how well it meets user requirements. What is the user requirement that you are attempting to address by forcing a user name entry?
 
If it is in a table in Access just add a table called UserID and use the Seek function on a data control like:

Private Sub cmdOk_Click()
'This is the exact code that use to require user names and passwords for my databases.


'Set index property required for seek
datUser.Recordset.Index = "PrimaryKey"

'Seek a record in the wp table with entered UserId
'I used datUser as the name of the data control
'I used

datUser.Recordset.Seek "=", UCase(txtUserID.Text)
If datUser.Recordset.NoMatch = True Then
Unload Me
'put what you want here to happen
End If

'If found, checks password for validity
'Only needed if you want to password so users cant enter other names
If UCase(txtPassword.Text) = UCase(datUser.Recordset("password").Value) Then
Unload Me
'put what you want to happen here
End If
End Sub

Another thing that you might want to do is use error trapping code like:

Private Sub txtUser_KeyPress(keyAscii as integer)
'This will make it so that no keys on the keyboard will work except for the letters.
'If they hit a key other than a letter then it just doesnt do anything.
'It's like turning off the keyboard :)

If KeyAscii >=97 And KeyAscii <= 122 Then
KeyAscii = KeyAscii - 32
End If

End Sub

I hope this helped :)
 
That 2nd part I listed is the wrong code lol. The code in the 2nd part of my above post is if you want text to be in all caps as it is being entered whether they have shift or caps lock on or not. This is the correct code for only allowing text with no numbers or symbols.

Private Sub txtUser_KeyPress(keyAscii as integer)

If KeyAscii < 97 And KeyAscii > 122 Then
KeyAscii = 0
End If

End Sub

Sorry about that :) got to typing too fast
 
Thanks guys,

Lets put it another way the user name is actually a name of a persen who is going to be using some equipmnet (NOT a user of the application). Sorry I should of made this clear from the start. I'm using a normal text field with no conditions or input masks. Any ideas appreciated.

Peps
 
Peps,

All of the above mentioned suggestions work on real names or user names. As long as you have a table with the names, you can verify against it. I would suggest going even an extra step and populating a drop down list box with the names and once one is selected, the record you are creating takes the name and adds it to the appropriate field.

Fred
 
I'm afraid I dont have a list I can get the names from. The names of users are not available before hand, neither do we now who is gonna use the gear until we get the guy through the door. It's a bit like a car rental service, you dont't know who the driver is until he comes through the door. I've thought about a condition that prevents users form entering a mimimum of charcters in that feild. I'll have a play, It's probably the best soloution. Peps
 
Yeah,

I see the delema. When you test for string length, you may also want to count only alpha characters and exclude the periods, commas etc from the count. In this way, you can be more assured that a name is being typed in. On a different note, do the users realize the need for accurate data? Sometimes (not all the time) when you can explain why a given piece of data is important, people are more responsive to following the rules.

Good luck.
 
To be honest they dont really care, the work sheets are going to another dept. The they have to trace the name from another source and then write in the name by hand. It dosent make a lot of sense when this can be avoided by putting the name in from the begining. I can appreciate that time is a factor, but it dont take that long to type a simple name in...

Thanks
Peps
 
Hi

If you cannot know the names of the users of the equipment in advance, how about at least recording the name (from their log in id) of the (system) users?

In my (too long) experince Users are exactly like the rest of us in at least two respects

1. they do no more work than is necessary (is that lazy or smart?)

2. if they make a mistake and there is no come back, they assume that data is a waste of time and cease to take care of it

In addition to that few users (or people) are deliberately obstructive, so if you explain why it is needed, and PROVE the need by feeding back to THEM, ommissions or errors, they will react by imrpoving the quality of their input.

So this is a management problem they need to police the situation and feed back errors and ommissions to those who are making them, if you do have deliberate obstructors or detroyers after that exercise then it is down to management to take appropriate action (in UK terms it is time for a P45).

You can dream up smart ideas fore-ever, a determined user will always outsmart you.

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
what i would do is trap the the userID that is entering the data, then do some analysis at a later date. my guess is that only a few users are actually lazy and entering spurious data. then turn this analysis into a manager/training issue.
alternately you could use a combo box and bind its data source to the user name field. limit it to list and on error have a custom form popup which tells the user that they are trying to enter a name not in the list, remind them of the importance of the user name.
If they wish to add the new user name to the list you could include a field which will write to the user name field thereby making it available in the combo box.
The harder you make it to be lazy, the less inclined the users will be to go down that route.

Be ALERT - Your country needs Lerts
 
Peps, try this:

Code:
Public Function CheckName(strName As String) As Boolean
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Purpose:      Check entry for a valid name
' Validation:   Must be at least two characters in length
'               Must contain at least two alphabet characters
'               Allowable ascii characters are as follows:
'                   32=space
'                   39=apostrophe
'                   45=hyphen
'                   65 to 90 = uppercase
'                   97 to 122 = lowercase
' Returns:      True if valid name
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Dim intChar As Integer      'number of alphabet characters
    Dim i As Integer            'counter
    
    
    If Len(strName) >= 2 Then
        For i = 1 To Len(strName)
            Select Case Asc(Mid(strName, i, 1))
                    ' allowable non-alphabet characters
                Case 32, 39, 45
                
                Case 65 To 90, 97 To 122
                    ' count alphabet characters - need at least 2
                    intChar = intChar + 1
                    
                Case Else
                        'rubbish typed - function returns FALSE
                    intChar = 0
                    Exit For
            End Select
        Next i
        
        If intChar >= 2 Then
            CheckName = True
        End If
    End If
End Function

Your test prior to printing the report is

Code:
If CheckName(Me.txtName) = True Then
    ' generate report here
Else
    MsgBox "Nice try - now put a REAL name in!", vbExclamation, _
        "Invalid Name"
End If

I've set the code to allow names of two characters in length (like "Jo") however if this is unlikely you might want to change the minimum number of characters to 3.
 
1) Either the details must be recorded somewhere. Where are they recorded? Or is this simply a report to print a convienent piece of paper?
2) Why is this your problem? Are you the manager? If not, that's where you go. It's essentially a business issue, not a tech one.

Craig
 
Hey

Copy this code into a module in access; it automatically gets the username of the logged-in user. For the on_click event of the button that prints the report just put in

Me.TEXTBOX = ap_GetUserName and that should be it.

Brian

'-- API Calls for getting the current user and computer names
Declare Function wu_GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) _
As Long
Declare Function wu_GetComputerName Lib "kernel32" Alias _
"GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) _
As Long


Function ap_GetUserName() As Variant

Dim strUserName As String
Dim lngLength As Long
Dim lngResult As Long

'-- Set up the buffer
'strUserName = String$(255, 0)
'lngLength = 255

strUserName = String$(20, 0)
lngLength = 20

'-- Make the call
lngResult = wu_GetUserName(strUserName, lngLength)

'-- Assign the value
ap_GetUserName = strUserName

End Function
 
Thanks for the Input, I can assure you this is really appreciated, although things are working, I'd like to get myself familiar with the KeyAscii function, Could someone tell me where I can find a list of characters and the Asc addresses.

Thanks again.
Peps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top