メインナビゲーションフォームのボタンへのアクセスを制御するために使用しているログイン画面があります。ユーザーのセキュリティレベルでどのボタンが表示されているかを判断したい。私の問題は、複数のbutton.visible = Falseを追加しようとするとフォームが壊れてしまい、見えないようにしようとしたトップボタンを見るだけです。私はVBAをコーディングするのにかなり新しい(私は基本的に先週、本を買った)、私はちょっと単純なものを見逃していると思う。誰も助けることができますか?コードは以下のとおりです。複数のボタンを使用してVBAにアクセスするbutton.visible = False
Private Sub Command1_Click()
Dim User As String
Dim UserLevel As Integer
Dim TempPass As String
Dim ID As Integer
Dim workerName As String
Dim TempLoginID As String
Dim SecLevel As String
If IsNull(Me.txtUserName) Then
MsgBox "Please enter UserName", vbInformation, "Please Enter your HealthcareID this is the same Id you use to log into windows"
Me.txtUserName.SetFocus
ElseIf IsNull(Me.txtPassword) Then
MsgBox "Please enter Pin Number", vbInformation, "Please enter your Pin Number"
Me.txtPassword.SetFocus
Else
If IsNull(DLookup("UserLogin", "tblUser", "UserLogin = '" & Me.txtUserName.Value & "' And password = '" & Me.txtPassword.Value & "'")) Then
MsgBox "Invalid UserName or Password! Use your HealthcareID as your username and your pin code to access."
Else
TempLoginID = Me.txtUserName.Value
workerName = DLookup("[UserName]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
UserSecurity = DLookup("[UserSecurity]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
TempPass = DLookup("[password]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
Unit = DLookup("[Unit]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
Unit = DLookup("[Unit]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
DoCmd.Close
Select Case UserSecurity
Case Is = 1 'Admins
DoCmd.OpenForm "Navigation Form"
Forms![Navigation Form]![TxtUser] = workerName
Forms![Navigation Form]![txtName] = TempLoginID
Forms![Navigation Form]![txtUnit] = Unit
Forms![Navigation Form]![txtUserSecurity] = UserSecurity
' DoCmd.BrowseTo acBrowseToForm, "frmFirstPage", "Navigation Form.NavigationSubForm", , , acFormEdit
Case Is = 2 'Managers
DoCmd.OpenForm "Navigation Form"
Forms![Navigation Form]![TxtUser] = workerName
Forms![Navigation Form]![txtName] = TempLoginID
Forms![Navigation Form]![txtUnit] = Unit
Forms![Navigation Form]!AdminPageButton.Visible = False
Forms![Navigation Form]![txtUserSecurity] = UserSecurity
' DoCmd.BrowseTo acBrowseToForm, "frmFirstPage", "Navigation Form.NavigationSubForm", , , acFormEdit
Case Is = 3 'Coordinators
DoCmd.OpenForm "Navigation Form"
Forms![Navigation Form]![TxtUser] = workerName
Forms![Navigation Form]![txtName] = TempLoginID
Forms![Navigation Form]![txtUnit] = Unit
Forms![Navigation Form]![txtUserSecurity] = UserSecurity
Forms![Navigation Form]!btnManagersMenu.Visible = False
Forms![Navigation Form]!AdminPageButton.Visible = False
' DoCmd.BrowseTo acBrowseToForm, "frmFirstPage", "Navigation Form.NavigationSubForm", , , acFormEdit
Case Else 'RCRs
DoCmd.OpenForm "Navigation Form"
Forms![Navigation Form]![TxtUser] = workerName
Forms![Navigation Form]![txtName] = TempLoginID
Forms![Navigation Form]![txtUnit] = Unit
Forms![Navigation Form]![txtUserSecurity] = UserSecurity
Forms![Navigation Form]!AdminPageButton.Visible = False
Forms![Navigation Form]!btnManagersMenu.Visible = False
Forms![Navigation Form]!btnCoordMenu.Visible = False
' DoCmd.BrowseTo acBrowseToForm, "frmFirstPage", "Navigation Form.NavigationSubForm", , , acFormEdit
End Select
End If
End If
End Sub
あなたの答えに基づいて、私は自分のコードで行ったタイプミスを見つけることができました。ありがとうございました! –
私は助けることができてうれしい! – JennyW