473,287 Members | 1,435 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,287 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 7059
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: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

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.