473,406 Members | 2,710 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,406 software developers and data experts.

Table names in listbox

365 100+
Good morning guys,
I have another one of my peculiar requests for ya...

As title suggests i would like a dynamic list of available tables so that the user can select one and it uses that value as a vb variable. im just not sure how to construct a table of such values? can it be done in sql or would i need to use a loop in vb?

cheers,
Dan
Jun 19 '09 #1
3 7075
ADezii
8,834 Expert 8TB
@Dan2kx
This is just 1 Method of accomplishing what you request, and it assumes your List Box Name is lstTableNames:
Expand|Select|Wrap|Line Numbers
  1. Dim tdf As DAO.TableDef
  2. Dim lst As ListBox
  3.  
  4. Set lst = Me![lstTableNames]
  5.  
  6. For Each tdf In CurrentDb.TableDefs
  7.   'Eliminate System Tables and Temporary Tables
  8.   If Left$(tdf.Name, 4) <> "MSys" And Left$(tdf.Name, 1) <> "~" Then
  9.     lst.AddItem tdf.Name
  10.   End If
  11. Next
And another Method
Expand|Select|Wrap|Line Numbers
  1. Dim strSQL As String
  2. Dim lst As ListBox
  3.  
  4. Set lst = Me![lstTableNames]
  5.  
  6. strSQL = "SELECT [Name] FROM MSysObjects WHERE [Type] = 1 And " & _
  7.          "Left$([Name], 4) <> 'MSys' And " & _
  8.          "Left$([Name], 1) <> '~' ORDER BY [Name];"
  9.  
  10. lst.RowSourceType = "Table/Query"
  11. lst.RowSource = strSQL
Jun 19 '09 #2
Dan2kx
365 100+
Genius ADezii

Thanks
Jun 19 '09 #3
ADezii
8,834 Expert 8TB
@Dan2kx
You are quite welcome.
Jun 19 '09 #4

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

Similar topics

2
by: Remco Groot Beumer | last post by:
Hello, I created a program in which I use modules and classmodules for setting my variables. For example when I need to set the customerID in a variable I use something like: ...
3
by: Danny | last post by:
I have code to allow the user to select any .mdb of his choice on the HD, but how do I then let him select a table from within this .mdb and then create a destination table of a name that I assign...
8
by: brian kaufmann | last post by:
Hi, I'm new to Access and this may be a basic question but I would appreciate it if you could let me know how to do this: I've created an Access table and would like to insert a column with...
13
by: Hrvoje Voda | last post by:
How to put a specified dataset table into an array list ? Hrcko
4
by: blee456 | last post by:
I have to create an attendance list for a meeting that will have attendees that are both on the committee and non member participants. My thinking is to create a form that has the member names...
5
by: EiEiO | last post by:
Hi All, I am trying to create an Import Form to "Map Fields" for importing many different tables into 1. The form I created has 2 columns of comboboxes ( A - AA) thru (J - JJ). The...
2
by: Arnold | last post by:
Greetings Gurus, In a report showing the names of students and their progress, I am getting an error in the name field (Name: #Error). The report gets its data from an unbound form containing...
1
by: JNariss | last post by:
Hello, I have created a form called frmS2P with the following: 1 listbox called List11 which holds the contents of a query created off my table called tblRequestActions. The fields which the...
1
by: Fix_Metal | last post by:
Hello all. I'm new to this group :) I have a problem with javascript language. I'm making an .asp page with some integrated Javascript functions. The page consists of some HTML selects and a...
1
by: Lynx101 | last post by:
Hi, hope you can help. Background: To find out who attended a meeting. Query: I have 2 list boxes: Listbox 1 = listing employees names
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.