I
Irshad Alam
Dear Sir/Madam,
I am trying to make for certain user read only form. I tried the below code.
It failed.
Below are the codes
These below are from module:====
Option Compare Database
Option Explicit
Declare Function apiGetUserName Lib "advapi32" Alias "GetUserNameA" (ByVal
buffer As String, BufferSize As Long) As Long
Declare Function apiGetComputerName Lib "kernel32" Alias "GetComputerNameA"
(ByVal buffer As String, BufferSize As Long) As Long
Function GetUserName() As String
'Wrapper for GetUserName API call.
'
'Procedure Syntax
'Dim strUserName As String
'strUserName = GetUserName
'Procedure Syntax
'
Dim strName As String
Dim lngSize As Long
Dim lngRetVal As Long
strName = Space(15)
lngSize = 15
lngRetVal = apiGetUserName(strName, lngSize)
GetUserName = left$(strName, lngSize - 1)
End Function
Function UserAccessInfo()
Dim frm As Form
If GetUserName = "mia" Then
With frm
..AllowAdditions = False
..AllowDeletions = False
..AllowEdits = False
End With
Else
With frm
..AllowAdditions = True
..AllowDeletions = True
..AllowEdits = True
End With
End If
End Function
*** Trying to call on the all the form opening :
Private Sub Form_Open(Cancel As Integer)
DoCmd.RunCommand acCmdRecordsGoToNew
Call UserAccessInfo
End Sub
Producing error
Run Time error No. 91 - object variable or with block variable not set
Please correct my code and advice.
Regards
Irshad
I am trying to make for certain user read only form. I tried the below code.
It failed.
Below are the codes
These below are from module:====
Option Compare Database
Option Explicit
Declare Function apiGetUserName Lib "advapi32" Alias "GetUserNameA" (ByVal
buffer As String, BufferSize As Long) As Long
Declare Function apiGetComputerName Lib "kernel32" Alias "GetComputerNameA"
(ByVal buffer As String, BufferSize As Long) As Long
Function GetUserName() As String
'Wrapper for GetUserName API call.
'
'Procedure Syntax
'Dim strUserName As String
'strUserName = GetUserName
'Procedure Syntax
'
Dim strName As String
Dim lngSize As Long
Dim lngRetVal As Long
strName = Space(15)
lngSize = 15
lngRetVal = apiGetUserName(strName, lngSize)
GetUserName = left$(strName, lngSize - 1)
End Function
Function UserAccessInfo()
Dim frm As Form
If GetUserName = "mia" Then
With frm
..AllowAdditions = False
..AllowDeletions = False
..AllowEdits = False
End With
Else
With frm
..AllowAdditions = True
..AllowDeletions = True
..AllowEdits = True
End With
End If
End Function
*** Trying to call on the all the form opening :
Private Sub Form_Open(Cancel As Integer)
DoCmd.RunCommand acCmdRecordsGoToNew
Call UserAccessInfo
End Sub
Producing error
Run Time error No. 91 - object variable or with block variable not set
Please correct my code and advice.
Regards
Irshad