473,832 Members | 2,122 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

access 2003 generate window selectors

22 New Member

I've been setting up a custom toolbar on start up for the application via VBA code.

I've generated, for the custom menu bar, the drop-down menus File, Edit, Window and Help and successfully added controls to each of them except for Window. I can't seem to add the funcitionality where upon opening a form it will add itself to the Window menu as an item so when it has lost focus it can be selected again.

I looped through a database default menu bar and figured out that the menu item that selects a window is of type 1, and id 830, the caption of the menu item (control) is &# Window Name

On the customized db I used the:

Expand|Select|Wrap|Line Numbers
  1.    Set cbcCutomMenuButton = cbcCutomMenu.Controls.Add(1,830)
  2.    With cbcCutomMenuButton
  3.     .Caption = "&1 Main Menu"
  4.    End With
If I try to set the id as 830 it yields an Add method error, If i don't, it doesn't do nothing upon clicking it.

If I generated a new application toolbar, I should be adding, for each form that is opened, a menu item into the drop down menu Window in the onopen event of the form?, with the control's onaction property set to focus the form, and on the onclose event to the form i should remove the menu item?

Is there any way to emulate the default toolbar behaviour?

Please advise, note that manually adding a menu item is not possible due to technical reasons (and because since I've been going at this thing for 3 hours without luck, and also because of my curiosity if this can be done :))

Thanks in advance and best regards,

Dec 11 '09 #1
2 1777
8,834 Recognized Expert Expert
Why not Hide the Original Custom Command Bar, Clone it whenever appropriate along with its Controls, then make it Visible, positioning it at the Top of the Window. All 'Opened' Windows will then be Visible in the Drop Down Window Menu. I executed this code against the Northwind Custom Menu Bar in the Sample Database and, although it is a rather rogue solution, it does work. Simply create a Function encapsulating the code, then call it whenever needed. I'm not really sure that this can be done in any other fashion. Good Luck.
Expand|Select|Wrap|Line Numbers
  1. Dim mbr As CommandBar
  2. Dim cbrCopy As CommandBar
  3. Dim cbr As CommandBarControl
  4. Dim ctl As CommandBarControl
  5. Dim cbrCtl As CommandBarControl
  6. Dim intOrigCount As Integer
  8. 'Customize with your own Name
  9. Const strCLONE_TBR_NAME As String = "Window_2"
  11. Application.CommandBars("NorthwindCustomMenuBar").Visible = False
  13. Set mbr = CommandBars("NorthwindCustomMenuBar")
  14. Set cbr = mbr.Controls("Window")
  16. 'DELETE if it exists to avoid ERROR
  17. Application.CommandBars(strCLONE_TBR_NAME).Delete
  19. 'Count of Controls on Original Command Bar
  20. intOrigCount = mbr.Controls.Count
  22. 'ADD the New Command Bar to the Collection, make Visible
  23. Set cbrCopy = CommandBars.Add(strCLONE_TBR_NAME)
  24.     cbrCopy.Visible = True
  26. 'Copy all Controls to the Cloned Command Bar
  27. For Each cbrCtl In mbr.Controls
  28.   cbrCtl.Copy cbrCopy
  29. Next cbrCtl
  31. 'Position at Top of Window
  32. cbrCopy.Position = msoBarTop
Dec 11 '09 #2
22 New Member

Thanks for the reply, will look into that.

Unfortunately my weekend didn't unfold as planned so I couldn't test this at home. I managed to write a couple of sub's which add the window name to the custom window menu on the onopen event, with the onaction property set to a generic fnFocusForm(frm name), and remove the button from the custom Window Menu it on the onclose event.

Feels like I'll have even more control over what the users are seeing.

I will try your approach later, I'd just have to loop thru the default Window Menu Window Selectors (that's what I call 'em, don't know if that's their right name) to see if I want the user to see that particular window.


Dec 14 '09 #3

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

Similar topics

by: George Hester | last post by:
I have a css file this is a portion of it: /* trackaccept.css */ div.track { width:400px; height: 100px; } I have this in my ASP page:
by: JustMe | last post by:
I don't know if this has anything to do with AccessXP running on Terminal Services with Access97/2000 also installed, but here is one example of a query that does not work any longer: SELECT DLookUp("MajorCategory","AutoTypes","='1'") AS MajorCategory, PreOwned.PaintColor FROM PreOwned; When I try to run the above query I get the following error:
by: BT Openworld | last post by:
I have just had to upgrade to Access 2003 as Access 97 EMail (SendObject) doesn't work when loaded on Windows XP. I'm finding my way around Access 2003 but my biggest problem is getting information. When I bought Access 1.0 many years ago, I got a paper manual and an excellent help file with all you needed to know. With Access 97 the manual came as a 'Building Applications' document on the CD and I still had the excellent help. With Access...
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much appreciated. Thanks in advance
by: Alicia | last post by:
If I wanted to create a table by hand create table temp( etc, where do I do it in access?
by: Robin | last post by:
Hi all, I'm working with a VB app, using DAO 3.6, that used to generate Access '97 databases using the following code: Set dbsNew = wrkDefault.CreateDatabase(strLPAccessInv, dbLangGeneral, dbVersion30) I was able to have it create databases in Access 2000 by changing "dbVersion30" to "dbVersion40". Do I generate a database in Access
by: Joe | last post by:
I have a table with a student id and course id. I would like to make both fields the primary key since a student can have multiple course ids but I do not want duplicate records. How would I go about creating the multiple field PK in Access 2003? Thanks!
by: Lyle Fairfield | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/callnetfrcom.asp The Joy of Interoperability Sometimes a revolution in programming forces you to abandon all that's come before. To take an extreme example, suppose you have been writing Visual Basic applications for years now. If you're like many developers, you will have built up a substantial inventory of code in that time. And if you've been following...
by: funfair | last post by:
HI,EVERY ONE first problem, i have create a database in access 2003 it worked fine untill i have format my laptop . now im working on office 2003 on windows xp and i have norton 2006 but im facing a problem in opening some forms from command button a message appear the openform action was canceled and when i open them from the database window(form) there are problem in open event or change event or activate event the same file is work...
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.