locking combo box on access 2003 using -'combobox'

locking combo box on access 2003  using -'combobox'

i want to allow only the administrators to change/update a combobox with the following code, but it returns an error that the Recordset is empty

Private Sub cboFeeCat_BeforeUpdate(Cancel As Integer)

Dim rsUserName As Recordset
Dim varsql As String
Dim strUser As String
Dim crtUser As String

crtUser = Forms!xaV!txtUser

varsql = "Select * from xaUser Where UserInit = '" & crtUser & "';"
Debug.Print varsql

Set rsUserName = gcdb.OpenRecordset(varsql)
While Not rsUserName.EOF
strUser = CStr(Trim(rsUserName("UserInit")))

If strUser = "Admin" Then
cboFeeCat.Locked = False
cboFeeCat.Locked = True
End If

End Sub


asked Sep 7, 2015 by rajesh
0 votes

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.