By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,826 Members | 2,443 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,826 IT Pros & Developers. It's quick & easy.

New Multiple Switchboards in an older large db.

P: 6
Hello!

I'm a relatively new 'grammer in Access/VBA and I'm taking over management of a database. It was requested that I add a login control to the database to ensure that everyone logged in properly, so that we can track who makes what changes through the forms.

I added different access levels -- based on what is set in the Employee table in the access_level field. Each access level opens a different menu. My problem is that each is named differently (Menu, Menu1, etc.) There are a LOT of forms that are triggered through this menu -- and they depend on the ComboEmployee box on the menu. I changed this to be set by the login screen and then disabled it. This way the name of the currently logged in user is visible on the menu, but not changeable unless they log out and back in.

The ComboEmployee is then used by all of the triggered forms to track who makes which changes, etc. Unfortunately, when the triggered forms are closed, they are looking to set the focus back to Menu (Forms![Menu].SetFocus). I'm not sure what to do if it should actually be setting the focus back to Menu1 or Menu2...as the case may be.

How do I find out which Menu triggered the form and have it be the object of the .SetFocus command?

Thanks for your help and/or suggestions!
Dec 19 '07 #1
Share this Question
Share on Google+
8 Replies


P: 10
Why not set up a couple of Public variables at logon time and grab the Logon Id and which menu the logon triggered. You will have this info available until the user logs out and you can use this info anywhere you need to create an audit trail of changes. Remember - keep it simple
Dec 19 '07 #2

P: 6
The reason I didn't do that (it was actually one of my first few thoughts) was because when I started building SQL queries, I could not find a way to access the public variable from the query builder.
Dec 19 '07 #3

jaxjagfan
Expert 100+
P: 254
The reason I didn't do that (it was actually one of my first few thoughts) was because when I started building SQL queries, I could not find a way to access the public variable from the query builder.
If you create an unbound textbox on the form and set the value of this unbound textbox to be the variable value you will be able to reference it using the QBE grid and query builder. If you don't want it to show but still reference the textbox change the colors (if form is white - set its background and border to transparent and forecolor to white - it's invisible in forrm view and still able to reference it in code and queries.
Dec 19 '07 #4

ADezii
Expert 5K+
P: 8,636
Hello!

I'm a relatively new 'grammer in Access/VBA and I'm taking over management of a database. It was requested that I add a login control to the database to ensure that everyone logged in properly, so that we can track who makes what changes through the forms.

I added different access levels -- based on what is set in the Employee table in the access_level field. Each access level opens a different menu. My problem is that each is named differently (Menu, Menu1, etc.) There are a LOT of forms that are triggered through this menu -- and they depend on the ComboEmployee box on the menu. I changed this to be set by the login screen and then disabled it. This way the name of the currently logged in user is visible on the menu, but not changeable unless they log out and back in.

The ComboEmployee is then used by all of the triggered forms to track who makes which changes, etc. Unfortunately, when the triggered forms are closed, they are looking to set the focus back to Menu (Forms![Menu].SetFocus). I'm not sure what to do if it should actually be setting the focus back to Menu1 or Menu2...as the case may be.

How do I find out which Menu triggered the form and have it be the object of the .SetFocus command?

Thanks for your help and/or suggestions!
  1. Are these 'Menus' Custom Menus or the standard Access Switchboards?
  2. Are Forms being opened using the OpenForm() Method or through the Switchboard interface?
  3. If you are using Custom Menus, are the Forms being opened within the Click() Event of Command Buttons? If not from where?
  4. Post some sample code illustrating your point.
Dec 19 '07 #5

P: 6
1. These menus are custom menus. All pre-existing from the original programmer.

2. These forms are being opened using the OpenForm() method:

Private Sub Lbl1_Click()
Dim stDocName As String
Dim stLinkCriteria As String
[formnom] = "FrmClients"
stDocName = "DLTech_Secure"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub

3. And, as you can see from the sample code above, the original programmer did not use buttons to launch the new windows. Labels were coded to respond to the Click() event. (he put blue images beneath as you can see from the following code):

Private Sub Lbl1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
lbl1.ForeColor = "16737843"
End Sub

Private Sub lbl1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Img1.Visible = True
Img1.Left = 94.122
Img1.Top = 1038.744
End Sub

These Click() methods are all launched from the custom menu MenuPrincipal. I created MenuPrincipal1 as a separate menu for a different access level. However when each of the new menus launched through the Click() method close, they use the following code to return to MenuPrincipal:

Private Sub Form_Close()
On Error Resume Next
[trackit] = 0
Forms![MenuPrincipal].SetFocus
End Sub


I'm not sure how to return to MenuPrincipal1 if that is the menu that launched the form... or when other menus are added, how to return to them. What is the difference between custom menus and Access Switchboards? Would it be better if I created Access Switchboards instead of using the pre-existing menu and creating MenuPrincipal1 and 2 and so on?
Dec 20 '07 #6

ADezii
Expert 5K+
P: 8,636
1. These menus are custom menus. All pre-existing from the original programmer.

2. These forms are being opened using the OpenForm() method:

Private Sub Lbl1_Click()
Dim stDocName As String
Dim stLinkCriteria As String
[formnom] = "FrmClients"
stDocName = "DLTech_Secure"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub

3. And, as you can see from the sample code above, the original programmer did not use buttons to launch the new windows. Labels were coded to respond to the Click() event. (he put blue images beneath as you can see from the following code):

Private Sub Lbl1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
lbl1.ForeColor = "16737843"
End Sub

Private Sub lbl1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Img1.Visible = True
Img1.Left = 94.122
Img1.Top = 1038.744
End Sub

These Click() methods are all launched from the custom menu MenuPrincipal. I created MenuPrincipal1 as a separate menu for a different access level. However when each of the new menus launched through the Click() method close, they use the following code to return to MenuPrincipal:

Private Sub Form_Close()
On Error Resume Next
[trackit] = 0
Forms![MenuPrincipal].SetFocus
End Sub


I'm not sure how to return to MenuPrincipal1 if that is the menu that launched the form... or when other menus are added, how to return to them. What is the difference between custom menus and Access Switchboards? Would it be better if I created Access Switchboards instead of using the pre-existing menu and creating MenuPrincipal1 and 2 and so on?
  1. The last Argument of the OpenForm() Method is OpenArgs, and you can place any String Expression here. In your case, place the name of the Menu which is opening the Form as in (FrmClients is being opened from Menu1):
    Expand|Select|Wrap|Line Numbers
    1. DoCmd.OpenForm "FrmClients", , , stLinkCriteria, acFormEdit, acWindowNormal, "Menu1"
  2. In the close Event of each Form, test that Form's OpenArgs Property, and return Focus to the proper Form:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub FrmClients_Close()
    2.   Select Case Me.OpenArgs
    3.     Case "Menu1"
    4.       Forms![Menu1].SetFocus
    5.     Case "Menu2"
    6.       Forms![Menu2].SetFocus
    7.     Case "Menu3"
    8.       Forms![Menu3].SetFocus
    9.     Case etc.
    10.       'I think you have the idea by now!
    11.   End Select
    12. End Sub
  3. Any questions, feel free to ask.
Dec 20 '07 #7

P: 6
Thank you for your time and help. Very much appreciated. :-)
Dec 21 '07 #8

ADezii
Expert 5K+
P: 8,636
Thank you for your time and help. Very much appreciated. :-)
You are quite welcome, let me know how you make out.
Dec 21 '07 #9

Post your reply

Sign in to post your reply or Sign up for a free account.