gold007eye
Registered User.
- Local time
- Today, 09:31
- Joined
- May 11, 2005
- Messages
- 260
Here is my dilema. I have a database where I have implented security levels (1-10) I have code on the "OnOpen" event that checks the users security level and then compares that level to a table called "Application Fields - NE" it then from this table determines which fields on the form are enabled/disabled or visible/not visible. This part is working fine.
What I would like to do is add the ability to "Lock" fields on the form using the same method, but when I add the line to Lock the fields (into the code) it is not locking the fields. I have added the extra field to the table (Yes/No) field. Does anyone have idea if there is a method I can use to do this?
Here is the code. I also attached an image of the table the data is coming from.
What I would like to do is add the ability to "Lock" fields on the form using the same method, but when I add the line to Lock the fields (into the code) it is not locking the fields. I have added the extra field to the table (Yes/No) field. Does anyone have idea if there is a method I can use to do this?
Here is the code. I also attached an image of the table the data is coming from.
Code:
On Error GoTo Err_Form_Open
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim strSql As String
'Dim ctl As Control
'For Each ctl In Me.Controls
'If Not Left(ctl.Name, 4) = "fixed_" Then
'ctl.Visible = False
'Me![Analyst].Visible = True
'Me![Analyst].SetFocus
'Me![Letter Type].Visible = True
'End If
'Next
' add the name of your form in place of 'YourForm'
strSql = "SELECT [Access Fields - Applications].Level, [Access Fields - Applications].Field, [Access Fields - Applications].Show, [Access Fields - Applications].Enabled FROM [Access Fields - Applications] WHERE ((([Access Fields - Applications].Level)='" & [Forms]![Applications - NE]![Security] & "'));"
Set qdf = CurrentDb.CreateQueryDef("", strSql)
Set rst = qdf.OpenRecordset
While Not rst.EOF
Me(rst!Field).Visible = rst!Show
Me(rst!Field).Enabled = rst!Enabled
Me(rst!Field).Locked = rst!Locked
If Me![Security] > 0 Then
Me![Save].Visible = True
Me![Add].Visible = True
Me![Modify].Visible = True
End If
rst.MoveNext
Wend
Set qdf = Nothing
Set rst = Nothing
Exit_Form_Open:
Exit Sub
Err_Form_Open:
Resume Exit_Form_Open
'------------ Code Break ----------------
Attachments
Last edited: