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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Secure Field After Initial Entry

Status
Not open for further replies.

nobull613

Technical User
Jun 6, 2003
76
US
I have a form where the user enters their initials when create the record. I'd like to keep the initials from being changed at a later date but allow changes to all other data in the form.

Basically, if someone goes to a previous record they can change anything BUT the initials.

Users use the same form for initial entries and edits of prior entries.

Any help would be greatly appreciated.

Thanks
 
You could use the current event for the form to check if you are in a new record (Me.NewRecord) and then programmatically lock the control.
 
How are ya nobull613 . . .

Example in the [blue]On Current[/blue] event of the form:
Code:
[blue]   If Trim(Me!YourTextboxName & "") <> "" Then
      Me!YourTextboxName.Locked = True
   Else
      Me!YourTextboxName.Locked = False
   End If[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
 
I was able to use the code to get it to work. Thanks a bunch.
 
I use these functions, not exacty sure where I got the code from.

Paste the code into a module

Add 2 Fields to the table/form
1)User
2)Computer
In the form set the default value for the fields

User Default =GetCurrentUserName()
Computer Default Value =GetComputerName()

You can then disable and lock the fields (or even make them invisible

Assuming users don't use the database under other users ID then you will know exactly who created the record, and from which computer





Private Declare Function GetComputerNameA Lib "kernel32" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function GetUserName Lib "ADVAPI32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Public Function GetComputerName() As String
On Error GoTo Err_GetComputerName
Dim Username As String * 255
Call GetComputerNameA(Username, 255)
GetComputerName = Left$(Username, InStr(Username, Chr$(0)) - 1)

Exit_GetComputerName:
Exit Function

Err_GetComputerName:
MsgBox Err.Description
Resume Exit_GetComputerName

End Function

Public Function GetCurrentUserName() As String
On Error GoTo Err_GetCurrentUserName
Dim lpBuff As String * 25
Dim ret As Long, Username As String
ret = GetUserName(lpBuff, 25)
Username = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
GetCurrentUserName = Username & ""

Exit_GetCurrentUserName:
Exit Function

Err_GetCurrentUserName:
MsgBox Err.Description
Resume Exit_GetCurrentUserName
End Function




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top