473,387 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

New Multiple Switchboards in an older large db.

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
8 1935
Peter99
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
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
254 Expert 100+
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
8,834 Expert 8TB
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
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
8,834 Expert 8TB
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
Thank you for your time and help. Very much appreciated. :-)
Dec 21 '07 #8
ADezii
8,834 Expert 8TB
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

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

Similar topics

2
by: Chris Bolus | last post by:
I'm a teacher using MS Access on an RMConnect 2.4 network. On some workstations both I and my students sometimes get an error message when attempting to insert a command button on a form which...
1
by: mary | last post by:
I am developing an Access db which will be used by multiple users. My questions are: Does MS Access have problems with multiple users accessing the db at once? If yes, what is your solution...
3
by: Colleyville Alan | last post by:
I am constructing a SQL command from a function. Some code builds the WHERE clause in a looping structure and passes that as an argument to the SQL-building function. But the results do not...
1
by: Claudia Fong | last post by:
Hello, I'm having problems to open a project that I made in VS 2005 in my laptop. I have an older version installed in my laptop (VS 2000 or 2002, I'm not sure right now). Is there a way so I...
5
by: vj | last post by:
Hi all, I am using C++Builder-5. I want to run multiple cpp files at the same time. If I use the C++Builder for running a cpp file (i.e., I just double click the cpp file, it then opens in the...
1
by: SSLProjects | last post by:
I am using switchboards in my database to make it easier for the users, however the exit function does not exit it loads a report any ideas on what I have doen wrong. I am not technical so have used...
1
by: allison | last post by:
I know that switchboards aren't loved in here, but I have a question about them. I have one database that runs in two locations. Can I make two main switchboards (one for each location) that goes...
1
by: Vivienne | last post by:
Hi there This is a hard problem that I have - I have only been using sql for a couple of weeks and have gone past my ability level quickly! The real tables are complex but I will post a simple...
2
by: Immortal Nephi | last post by:
You may have heard diamond shape. You create one base class. One base class has member functions and member variables. You create two derived classes. All member functions and member variables...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.