Access: Protect form with different passwords that start a different macro depending on the input

Anonymous
2022-11-09T13:23:45.007+00:00

Hello everyone
I would like to achieve the following with the following code: When opening the form, a password prompt appears, there are 2 different passwords. Depending on which one is entered, a macro should be started. When switching from draft to form view, he also asks for the password, here my code works. Only when I reopen the form does the error number 2046 appear, and according to the debugger the macro is the problem.

Private Sub Form_Open(Cancel As Integer)
Select Case InputBox("Passwort eingeben", "Passwortabfrage")
Case "DAH"
DoCmd.RunMacro "Mak_PL_DAH"
Case "LEF"
DoCmd.RunMacro "Mak_PL_LEF"
Case Else
MsgBox "Falsch"
DoCmd.Close acForm, Me.Name
End Select
End Sub

Can anyone help me? :-)
Greetings Carolin

Access Development
Access Development
Access: A family of Microsoft relational database management systems designed for ease of use.Development: The process of researching, productizing, and refining new or existing technologies.
859 questions
{count} votes