If VBA

Dannyc989

Registered User.
Local time
Today, 20:15
Joined
Dec 18, 2013
Messages
46
Hi Folks, I have seen the answer I want before but now cant find it again.

All I want to do is have some code for when a form opens:

if Access Level = Sales then open Form Sales and so on could anyone please show me the code I want??

cheers

Daniel
 
Code:
if [Access Level] = "Sales" then
   docmd.openForm "Sales"
endif
' and so on
 
Can Anyone tell me what is wrong with this??

Private Sub Form_Open(Cancel As Integer)
If [AccessLevel] = "Sales" Then
DoCmd.OpenForm "Sales"

Else
If [AccessLevel] = "Manager" Then
DoCmd.OpenForm "Manager"

Else
If [AccessLevel] = "Service" Then
DoCmd.OpenForm "Service"

Else
If [AccessLevel] = "Operator" Then
DoCmd.OpenForm "Operator"

Else
If [AccessLevel] = "Administrator" Then
DoCmd.OpenForm "Administrator"
End If
DoCmd.Close "AccessLevel"
End Sub
 
Yes; each If must have an End If. If every level has a form, simply

DoCmd.OpenForm [AccessLevel]
 

Users who are viewing this thread

Back
Top Bottom