By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,652 Members | 1,460 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,652 IT Pros & Developers. It's quick & easy.

Switchboard to tables

P: n/a
I would like to create a switchboard showing all tables that would open each
table upon selecting the control box. The switchboard manager does not
appear to allow you to select specific tables as you can do in forms and
reports. Is anyone aware of a way to do this?

Oct 13 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Yetti wrote:
I would like to create a switchboard showing all tables that would open each
table upon selecting the control box. The switchboard manager does not
appear to allow you to select specific tables as you can do in forms and
reports. Is anyone aware of a way to do this?
I would do it another way.

Create a new form in Design mode.

Click the Toolbox toolbar to add a listbox.

Drop the listbox on the form. Don't go thru the wizard, cancel when
dragged to it. The name of the listbox, in my code, is List0. If you
use a different name, change any code refs from List0 to your ref name

Open the property sheet for the Listbox by dbl-clicking on the listbox.
Click the Data tab. In the ROWSOURCETYPE, not ROWSOURCE, enter
FillListBox
Now click the "Other" tab to ensure MultiSelect is set to None.

I have provided some code. Copy/Paste the entire code below where you
see the word StartCut. Open up the code module for the form. Paste the
code. Save the code, save the form.

Now open up the form. You will see a list of all of your tables.
Dbl-click on one. It will open the table.

Now you can open the switchboard and have it open this new form.

'startcut here
Option Compare Database
Option Explicit
Private Type ListElements
strTableName As String
End Type
Private Function FillListBox(fld As Control, ID As Variant, row As
Variant, col As Variant, Code As Variant) As Variant
Static strRows() As ListElements
Static Entries As Integer
Dim strTableNameID As Long
Dim tdf As TableDef

Dim ReturnVal As Variant

ReturnVal = Null

Select Case Code
Case acLBInitialize ' Initialize.
'Docmd.Hourglass true
Entries = 0
ReDim Preserve strRows(Entries)

strRows(Entries).strTableName = "Table Name"

For Each tdf In CurrentDb.TableDefs
If Left(tdf.name, 4) <"MSys" Then
Entries = Entries + 1
ReDim Preserve strRows(Entries)
strRows(Entries).strTableName = tdf.name
End If
Next

ReturnVal = True
Case acLBOpen ' Open.
ReturnVal = Timer ' Generate unique ID for control.
Case acLBGetRowCount ' Get number of rows.
ReturnVal = Entries + 1
Case acLBGetColumnCount ' Get number of columns.
ReturnVal = 1
Case acLBGetColumnWidth ' Column width.
ReturnVal = -1 ' -1 forces use of default width.
Case acLBGetValue ' Get data.
ReturnVal = strRows(row).strTableName
Case acLBEnd ' End.
Erase strRows
End Select
FillListBox = ReturnVal
End Function
Private Sub List0_DblClick(Cancel As Integer)
DoCmd.OpenTable Me.List0
End Sub
Oct 13 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.