Field Level

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can somebody help me? I have a database and 2 Tables.
One table keeps some information (tblMain))and another is for login.
I have a form to enter record (entry) data into tblMain called frmMain.
In Main Table I have also a field with keeps the username for the user that
addNew record.
When a modification needs for same record I need my procedure to much
UseName(actual loged) whith that is saved in and only then to allow to modify.
In other words: if "SmithP" is owner of a record only SmithP can modify it.
 
Can somebody help me? I have a database and 2 Tables.
One table keeps some information (tblMain))and another is for login.
I have a form to enter record (entry) data into tblMain called frmMain.
In Main Table I have also a field with keeps the username for the user that
addNew record.
When a modification needs for same record I need my procedure to much
UseName(actual loged) whith that is saved in and only then to allow to modify.
In other words: if "SmithP" is owner of a record only SmithP can modify it.

You could basically "lock" your form if the current user is not the record's owner. You'd do this in the Form's Current
event, which fires every time you move in the recordset:

Sub Form_Current()
Me.AllowEdits = Me.YourUserNameField = UserName
End Sub

This assumes that UserName is a variable containg the name of the currently logged-in user, or is a Function that
returns the same.

Scott McDaniel
scott@takemeout_infotrakker.com
www.infotrakker.com
 
Use:
Me.AllowEdits = (Me.UserNamefield = LogInName())

Public Function LogInName() As String
'This function returns the current user's network log-in name (eg
MILEWSKP).
'If the user name is longer than MaxLen, "" is returned.

Dim s As String
Dim L As Long 'Length of null terminated UserName string
Const MaxLen As Integer = 999 'Max length of UserName - 1

On Error GoTo UnexpectedError

L = MaxLen
s = Space(L)
Call GetUserName(s, L) 'S = UserName & Null character; if
Len(UserName& Null) > MaxLen then S = zero or more blank
LogInName = UCase(Left(s, L - 1)) 'Strip off excess characters

End Function
 
Back
Top