Switchboard list box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • smoothmunkey
    New Member
    • Jun 2007
    • 1

    #1

    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
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by smoothmunkey
    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 - pgeDataAccessPa ge

      [CODE=vb]Private Sub lstDBObjects_Af terUpdate()
      Dim strObjectToOpen As String
      strObjectToOpen = Me![lstDBObjects]

      Select Case Left$(strObject ToOpen, 3)
      Case "frm"
      DoCmd.OpenForm strObjectToOpen , acNormal, , , acFormEdit
      Case "qry"
      DoCmd.OpenQuery strObjectToOpen , acViewNormal, acReadOnly
      Case "mcr"
      DoCmd.RunMacro strObjectToOpen
      Case "tbl"
      DoCmd.OpenTable strObjectToOpen , acViewNormal, acEdit
      Case "mdl"
      DoCmd.OpenModul e strObjectToOpen
      Case "rpt"
      DoCmd.OpenRepor t strObjectToOpen , acViewNormal, , , acWindowNormal
      Case "pge"
      DoCmd.OpenDataA ccessPage strObjectToOpen , acDataAccessPag eBrowse
      Case Else
      End Select
      End Sub
      [/CODE]

    Comment

    Working...