473,385 Members | 1,944 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,385 software developers and data experts.

access 2003 generate window selectors

Hi

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
  5.  
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,

Afro
Dec 11 '09 #1
2 1747
ADezii
8,834 Expert 8TB
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
  7.  
  8. 'Customize with your own Name
  9. Const strCLONE_TBR_NAME As String = "Window_2"
  10.  
  11. Application.CommandBars("NorthwindCustomMenuBar").Visible = False
  12.  
  13. Set mbr = CommandBars("NorthwindCustomMenuBar")
  14. Set cbr = mbr.Controls("Window")
  15.  
  16. 'DELETE if it exists to avoid ERROR
  17. Application.CommandBars(strCLONE_TBR_NAME).Delete
  18.  
  19. 'Count of Controls on Original Command Bar
  20. intOrigCount = mbr.Controls.Count
  21.  
  22. 'ADD the New Command Bar to the Collection, make Visible
  23. Set cbrCopy = CommandBars.Add(strCLONE_TBR_NAME)
  24.     cbrCopy.Visible = True
  25.  
  26. 'Copy all Controls to the Cloned Command Bar
  27. For Each cbrCtl In mbr.Controls
  28.   cbrCtl.Copy cbrCopy
  29. Next cbrCtl
  30.  
  31. 'Position at Top of Window
  32. cbrCopy.Position = msoBarTop
Dec 11 '09 #2
Hi

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(frmname), 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.

Regards,

Afro
Dec 14 '09 #3

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

Similar topics

11
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:
23
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...
2
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...
6
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...
2
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?
3
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,...
1
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...
5
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...
1
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...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...
0
jinu1996
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...

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.