Run code before close report (1 Viewer)

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 02:09
Joined
May 7, 2009
Messages
19,169
you put it here:
Code:
Select Case [Forms]![FormLogin].[txtDienstID]
       Case 1, 2, 5, 8
            CurrentDb.Properties("AllowShortcutMenus") = True
       Case Else
            CurrentDb.Properties("AllowShortcutMenus") = False
       End Select

Tempvars.Add "allow_shortcut", (Instr(1, ",1,2,5,8", "," & [Forms]![FomLogin]![txtDienstID] & ",") > 0)

now on open event of all Reports:
Code:
Private Sub Report_Open(Cancel As Integer)
If [Tempvars]![allow_shortcut] = False Then
   'not admins
    Me.ShortcutMenuBar = "menu_print2"
Else
    Me.ShortcutMenuBar = "menu_print"
End If
End Sub
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 02:09
Joined
May 7, 2009
Messages
19,169
or to make it simple:
Code:
Select Case [Forms]![FormLogin].[txtDienstID]
       Case 1, 2, 5, 8
            CurrentDb.Properties("AllowShortcutMenus") = True
       Case Else
            CurrentDb.Properties("AllowShortcutMenus") = False
       End Select

Code:
Private Sub Report_Open(Cancel As Integer)
If (CurrentDb.Properties("AllowShortcutMenus")) = True Then
   'admins
    Me.ShortcutMenuBar = "menu_print"
Else
    Me.ShortcutMenuBar = "menu_print2"
End If
End Sub
 

scallebe

Registered User.
Local time
Today, 19:09
Joined
Mar 23, 2018
Messages
51
arnelgp,

That's where I'm a little confused,

Do I put in the Loginform or in a module?:confused:
 

scallebe

Registered User.
Local time
Today, 19:09
Joined
Mar 23, 2018
Messages
51
Arnelgp,

To enable or disable the shortcutmenu for all forms the code is placed in every on open event of the form. And only the forms who are available for users. Not in the Admin forms.

So where do I place the code :

Code:
Select Case [Forms]![FormLogin].[txtDienstID]
       Case 1, 2, 5, 8
            CurrentDb.Properties("AllowShortcutMenus") = True
       Case Else
            CurrentDb.Properties("AllowShortcutMenus") = False
       End Select

I think because you set CurrentDB.properties…. it goes in a module. But I don't know how. :confused:

The report Open event that I understand…

Thank you for your patience :rolleyes:

Greetz

Pascal :cool:
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 02:09
Joined
May 7, 2009
Messages
19,169
for code in post #24, you put it same as in post #13.
 

scallebe

Registered User.
Local time
Today, 19:09
Joined
Mar 23, 2018
Messages
51
arnelgp,

The code in post #13 is in all forms (for users) in the on open event to enable or disable the shortcutmenu in the forms.

Now I want to use the print_menu & print_menu2 in the repports.

I can't believe that's the intention to put the code in post #24 in the on open event of all forms (for users)

Or am I wrong? :confused:

Thanks
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 02:09
Joined
May 7, 2009
Messages
19,169
do you have code for your login form (FormLogin)? what is txtDienstID, is it a textbox?
if it is add code to its AfterUpdate and put the code there:
Code:
Private Sub txtDienstID_AfterUpdate()
Select Case Me![txtDienstID]
       Case 1, 2, 5, 8
            CurrentDb.Properties("AllowShortcutMenus") = True
       Case Else
            CurrentDb.Properties("AllowShortcutMenus") = False
       End Select
End Sub
 

scallebe

Registered User.
Local time
Today, 19:09
Joined
Mar 23, 2018
Messages
51
arnelgp,

I didn't work in the afterupdate event of the textbox.

My LoginForm stays open but hidden after input password. For various reasons. In many cases I refer to certain data in that form... one of them is DienstID...

So I put the code in the FormLogin load event and the other part in the report open event and….. it works perfect....

Finally :banghead::banghead:

Thank you so much, it was a productive day today :rolleyes:

Enjoy the rest of the weekend

Greetz

Pascal
 

Users who are viewing this thread

Top Bottom