aron.ridgway
Registered User.
- Local time
- Today, 01:01
- Joined
- Apr 1, 2014
- Messages
- 148
Hi There i have the following code that hides 5 buttons depending if the user has permission which works fine.
im trying to incorporate an IF statement if there is only 1 of the buttons visible then to automatically click the button. but if there is more than 1 do noting?
im trying to incorporate an IF statement if there is only 1 of the buttons visible then to automatically click the button. but if there is more than 1 do noting?
Code:
Private Sub Form_Open(Cancel As Integer)
Dim rsO As DAO.Recordset
Set rsO = CurrentDb.OpenRecordset("SELECT tblUserPermission.UserFK, tblUserPermission.CompanyFK, tblUserPermission.Permission " & _
"FROM tblUserPermission INNER JOIN tblUser ON tblUserPermission.UserFK = tblUser.UserPK " & _
"WHERE Username = '" & Me.txtName.Value & "'")
Do While Not rsO.EOF
Select Case rsO.Fields("CompanyFK")
Case 1
Me.cmdRWL.Visible = rsO.Fields("Permission")
Me.lblRWL.Visible = rsO.Fields("Permission")
Case 2
Me.cmdFAH.Visible = rsO.Fields("Permission")
Me.lblFAH.Visible = rsO.Fields("Permission")
Case 3
Me.cmdRFG.Visible = rsO.Fields("Permission")
Me.lblRFG.Visible = rsO.Fields("Permission")
Case 4
Me.cmdRFP.Visible = rsO.Fields("Permission")
Me.lblRFP.Visible = rsO.Fields("Permission")
Case 5
Me.cmdRFW.Visible = rsO.Fields("Permission")
Me.lblRFW.Visible = rsO.Fields("Permission")
End Select
rsO.MoveNext
Loop
Set rsO = Nothing
End Sub