468,309 Members | 1,074 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,309 developers. It's quick & easy.

Switchboard list box

I want to make a switchboard with a list box to open objects... but i want the list box to be dynamic (as new queries or forms are created, i want them added). so far i have a combo box that selects the type of object (tables, forms, etc.) and a list box that lists all the objects of the type selected in the combo box. but i cannot figure out how to open the objects out of the list box. any help would be much appreciated. (the idea behind the form is that it replaces the database window to prevent users from breaking the database)

thanks in advance
Jun 26 '07 #1
1 1863
ADezii
8,799 Expert 8TB
I want to make a switchboard with a list box to open objects... but i want the list box to be dynamic (as new queries or forms are created, i want them added). so far i have a combo box that selects the type of object (tables, forms, etc.) and a list box that lists all the objects of the type selected in the combo box. but i cannot figure out how to open the objects out of the list box. any help would be much appreciated. (the idea behind the form is that it replaces the database window to prevent users from breaking the database)

thanks in advance
The easiest Method by far is to preface Database Objects with the appropriate 3-character prefixes, then place this code in the AfterUpdate() Event of the List Box as in:
  1. Forms - frmFormName
  2. Queries - qryQueryName
  3. Macros - mcrMacroName
  4. Tables - tblTableName
  5. Modules - mdlModuleName
  6. Reports - rptReportName
  7. Data Access Pages - pgeDataAccessPage

    Expand|Select|Wrap|Line Numbers
    1. Private Sub lstDBObjects_AfterUpdate()
    2. Dim strObjectToOpen As String
    3. strObjectToOpen = Me![lstDBObjects]
    4.  
    5. Select Case Left$(strObjectToOpen, 3)
    6. Case "frm"
    7.   DoCmd.OpenForm strObjectToOpen, acNormal, , , acFormEdit
    8. Case "qry"
    9.   DoCmd.OpenQuery strObjectToOpen, acViewNormal, acReadOnly
    10. Case "mcr"
    11.   DoCmd.RunMacro strObjectToOpen
    12. Case "tbl"
    13.   DoCmd.OpenTable strObjectToOpen, acViewNormal, acEdit
    14. Case "mdl"
    15.   DoCmd.OpenModule strObjectToOpen
    16. Case "rpt"
    17.   DoCmd.OpenReport strObjectToOpen, acViewNormal, , , acWindowNormal
    18. Case "pge"
    19.   DoCmd.OpenDataAccessPage strObjectToOpen, acDataAccessPageBrowse
    20. Case Else
    21. End Select
    22. End Sub
    23.  
Jun 27 '07 #2

Post your reply

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

Similar topics

1 post views Thread by jimwlee | last post: by
1 post views Thread by Yetti | last post: by
6 posts views Thread by keri | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.