Hi all,
I am using a form to allow access to a table to change passwords. In the header, I have a drop-down for Dept. and a textbox for the user to type the password. On hitting cmdOK, I check their choices via SQL and allow or disallow access to the detail section.
I have done this by setting all the detail controls' visible property to false in design, and if they match the dept and password, the controls visible prop is set to true. I used a for-loop to cycle through the controls of the detail section to accomplish this.
Everything works beautifully, except that I'd now like to hide the detail section of the form itself and only show the header on opening. I've tried the same scenario and added a single line to my code to set the form's detail section.visible to true, but it won't come back!
Here's the code so far:
Private Sub cmdOKEnter_Click()
Dim cnn As ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strSQL As String
Dim strPwd As String
Dim strDept As String
Set cnn = CurrentProject.Connection
If Len(Me.cboChooseDept & "") > 0 And Len(Me.txtEnterPwd & "") > 0 Then
strDept = cboChooseDept
strPwd = txtEnterPwd
Else
MsgBox "You must choose a Department and Enter a Password!", vbExclamation + vbOKOnly, "Incomplete Info"
End If
strSQL = "Select * FROM tblProcedMaintSecurity WHERE txtMngrPwd = '" & strPwd & "'" & " AND txtDept = '" & Me.cboChooseDept & "'"
rs.Open strSQL, cnn, adOpenStatic
If rs.RecordCount > 0 Then
DoCmd.ApplyFilter , "txtMngrPwd = '" & strPwd & "'and txtDept='" & Me.cboChooseDept & "'"
Me.Detail.Visible = True
For Each ctl In [Forms]![frmProcedMaintSecurity].Detail.Controls
If ctl.Tag = "Off" Then
Else
ctl.Visible = True
End If
Next ctl
Else
MsgBox "You are not authorized to use this feature!", vbOKOnly + vbCritical, "Password Incorrect!"
Exit Sub
End If
End Sub
I hope someone can help,
Thanks in advance,
Tru
I am using a form to allow access to a table to change passwords. In the header, I have a drop-down for Dept. and a textbox for the user to type the password. On hitting cmdOK, I check their choices via SQL and allow or disallow access to the detail section.
I have done this by setting all the detail controls' visible property to false in design, and if they match the dept and password, the controls visible prop is set to true. I used a for-loop to cycle through the controls of the detail section to accomplish this.
Everything works beautifully, except that I'd now like to hide the detail section of the form itself and only show the header on opening. I've tried the same scenario and added a single line to my code to set the form's detail section.visible to true, but it won't come back!
Here's the code so far:
Private Sub cmdOKEnter_Click()
Dim cnn As ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strSQL As String
Dim strPwd As String
Dim strDept As String
Set cnn = CurrentProject.Connection
If Len(Me.cboChooseDept & "") > 0 And Len(Me.txtEnterPwd & "") > 0 Then
strDept = cboChooseDept
strPwd = txtEnterPwd
Else
MsgBox "You must choose a Department and Enter a Password!", vbExclamation + vbOKOnly, "Incomplete Info"
End If
strSQL = "Select * FROM tblProcedMaintSecurity WHERE txtMngrPwd = '" & strPwd & "'" & " AND txtDept = '" & Me.cboChooseDept & "'"
rs.Open strSQL, cnn, adOpenStatic
If rs.RecordCount > 0 Then
DoCmd.ApplyFilter , "txtMngrPwd = '" & strPwd & "'and txtDept='" & Me.cboChooseDept & "'"
Me.Detail.Visible = True
For Each ctl In [Forms]![frmProcedMaintSecurity].Detail.Controls
If ctl.Tag = "Off" Then
Else
ctl.Visible = True
End If
Next ctl
Else
MsgBox "You are not authorized to use this feature!", vbOKOnly + vbCritical, "Password Incorrect!"
Exit Sub
End If
End Sub
I hope someone can help,
Thanks in advance,
Tru