Results 1 to 6 of 6
  1. #1
    tsn.s is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Location
    Selby, North Yorkshire, UK
    Posts
    19

    Using a combo box for selecting a form

    Hi

    I am currently working on a database that has a main menu form which leads to many other sub-menu forms. I would like the sub-menus to selected from a drop down list on the main menu as there are so many sub-menus that it makes the main menu look 'messy' having them all as buttons on the main menu.



    I hope I've explained it clear enough. Any help is much appreciated.

    Thanks

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Create your combo box. On a form, add a command button, and put this code on the onclick event.

    Code:
    Private Sub Command2_Click()
    On Error GoTo Err_Command2_Click
        Dim stDocName As String
        Dim stLinkCriteria As String
        stDocName = Me.cboMyForms.Value
        DoCmd.OpenForm stDocName, , , stLinkCriteria
    Exit_Command2_Click:
        Exit Sub
    Err_Command2_Click:
        MsgBox Err.Description
        Resume Exit_Command2_Click
        
    End Sub
    Change your combobox name appropriately. I had never thought of doing this. I like the idea and will employ it personally in the future. It will make for a cleaner sharper look.

    Alan

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Along with Alan's code for the button, you could use this as a base for your Forms to be displayed. You may have a naming convention that would assist in the actual forms to be presented.

    Use this as the row Source of the Combo

    SELECT MsysObjects.Name FROM MsysObjects WHERE (((MsysObjects.Name) Not Like '~*') AND ((MsysObjects.Type)=-32768)) ORDER BY MsysObjects.Name;
    Good luck

    Edit: I tried it with the sample row source and a button. I agree with Alan's comment - it looks good - cleaner and sharper and works great.

  4. #4
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Orange: Thanks for the update on using the system tables. I had forgot that as an option. Makes it even a better solution as you don't need to build a table. OOOOH! I love it when someone spurs an idea and you take it to an out of the box concept.

    BTW: Type code for Queries is 5 and type code for tables is 1.

    Alan

  5. #5
    tsn.s is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Location
    Selby, North Yorkshire, UK
    Posts
    19
    Thanks Alan and Orange.

    It works and looks great! I hope you find use for it in the future.

    Thanks

    tsn.s

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Alan and I are glad you have it working. Happy to help.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Selecting records within a form
    By crowegreg in forum Programming
    Replies: 29
    Last Post: 08-19-2011, 08:18 AM
  2. Replies: 5
    Last Post: 07-04-2011, 12:53 PM
  3. Selecting Items in a combo box
    By Ferdi in forum Programming
    Replies: 6
    Last Post: 03-15-2011, 09:12 AM
  4. selecting Sub-Form data from two inputs
    By techexpressinc in forum Queries
    Replies: 19
    Last Post: 12-03-2010, 11:03 AM
  5. Replies: 5
    Last Post: 04-01-2010, 03:48 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums