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

Make some records view only

Status
Not open for further replies.

zrobinso

MIS
Apr 22, 2001
27
US
I have a database and need to limit records a user can edit.

On records where the user is the author, I need it to enter their author number from a login table. The author needs full access of records they have entered. But they need view permissions on records they are not the author.

All records will be entered through a form.

Thanks,

Z
 
Use code in the form's Current event to test whether the user is the author of this record. If so, unlock all the controls they're allowed to update. If not, lock all the controls. To lock a control, set its Locked property to True. Rick Sprague
 
Hallo,

Alternatively, if multiple records are displayed on the form, make the form read-only, then put an Edit... button on the form. When the edit button is clicked and the user is the author another form containing just the editable record is displayed.

Here's some code to get the user's login name:
Code:
'The GetUserName function retrieves the user name of the current thread, the user currently logged onto the system
Public Declare Function lngGetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Public Function strGetUserName() As String
On Error GoTo Err_strGetUserName
  
  Const cintBufferLength As Integer = 255
  Dim strBuffer As String * cintBufferLength
  Dim lngSize As Long

  lngSize = cintBufferLength

  If lngGetUserName(strBuffer, lngSize) <> 0 Then
    strGetUserName = left$(strBuffer, lngSize - 1)
  Else
    strGetUserName = &quot;&quot;
  End If

Exit_strGetUserName:
  Exit Function
Err_strGetUserName:
  strGetUserName = &quot;&quot;
  Resume Exit_strGetUserName
End Function
It works on NT 4 and W98SE. Hope that helps,

- Frink
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top