Security

Knight of Nee

Board Regular
Joined
Aug 4, 2003
Messages
124
Hi.

Is it possible to lock only one field in a table depending a username supplied when the user is logged in using Access user groups/permissions?.

If not what other solutions are there to solving my problem

Thanks
KON
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Not in a query but yes in a form.

Start out by requiring the user to utilize your custom built forms to open the tables & queries. In the form, set the Locked property of the textbox displaying this particular field to True.

As to the username question - yes. I've never tried to grab it but it simply has to be an available property inside Access (the username logged into the mdb). Peek thru the object browser. You can put a check into the forms open/load event that grabs the currently logged in name and then does the above action based on what it finds.

Mike
 
Upvote 0
The following API call will return the logged in user:
Code:
Private Declare Function WNetGetUser Lib "mpr.dll" Alias "WNetGetUserA" (ByVal lpName As String, ByVal lpUserName As String, lpnLength As Long) As Long

Private Const NO_ERROR = 0
Private Const ERROR_NOT_CONNECTED = 2250&
Private Const ERROR_MORE_DATA = 234
Private Const ERROR_NO_NETWORK = 1222&
Private Const ERROR_EXTENDED_ERROR = 1208&
Private Const ERROR_NO_NET_OR_BAD_PATH = 1203&

Function WinUsername() As String

    Dim strBuf As String, lngUser As Long, strUn As String
    
    strBuf = Space$(255) 'Clear buffer
    
    lngUser = WNetGetUser("", strBuf, 255)
    
    If lngUser = NO_ERROR Then
        strUn = Left(strBuf, InStr(strBuf, vbNullChar) - 1)
        WinUsername = strUn
    Else
        WinUsername = "Error :" & lngUser
    End If

End Function

Hope this helps,
 
Upvote 0
Corticus,

That grabs the userid logged into the network/workstation.
He's asking for the userid logged into the mdb using the Access Security features.

I just now dug this up over on:
http://support.microsoft.com/default.aspx?scid=/support/access/content/secfaq.asp

Seems to do the job.

Code:
  Function User_in_mdb()
      Dim ws As Workspace

      Set ws = DBEngine.Workspaces(0)
      Debug.Print ws.UserName

   End Function
Mike
 
Upvote 0

Forum statistics

Threads
1,221,831
Messages
6,162,242
Members
451,756
Latest member
tommyw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top