Fill listbox with numbers

P

Phil

How can I fill a list box with numbers, I have a textbox [Nooftable] wher I
enter the number of tables, I would then like the listbox to have a list of
the tables

e.g

textbox = 6

List box =

1
2
3
4
5
6


Ideally I would like it to say "table 1" ... etc but that is something I can
sort out later

Hope someone can help

Thanks

Phil
 
A

Allen Browne

Set the Row Source of the list box to:

SELECT MsysObjects.Name FROM MsysObjects
WHERE (([Type] = 1)
AND ([Name] Not Like "~*")
AND ([Name] Not Like "MSys*"))
ORDER BY MsysObjects.Name;

Incldue types 6 and 4 for linked tables and ODBC linked tables respectively.
 
P

Phil

Hi Allen

Sorry, it is my useless explanation, I am trying to build a seat planner
onto my existing events planner.

The textbox Nooftables refers to the number of tables at the venue, I
wanted to create a listbox with a list of the tables so I can select a table
and see who is on that table (in another listbox). I am just struggling to
populate the Listbox, I need a list of tables

e.g No of tables available = 6

List Box shows

1
2
3
4
5
6

I can then select the table and assign people to that table, or veiw the table

By the way your code worked perfectly first time!

Thanks

Phil

Allen Browne said:
Set the Row Source of the list box to:

SELECT MsysObjects.Name FROM MsysObjects
WHERE (([Type] = 1)
AND ([Name] Not Like "~*")
AND ([Name] Not Like "MSys*"))
ORDER BY MsysObjects.Name;

Incldue types 6 and 4 for linked tables and ODBC linked tables respectively.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.
Phil said:
How can I fill a list box with numbers, I have a textbox [Nooftable] wher
I
enter the number of tables, I would then like the listbox to have a list
of
the tables

e.g

textbox = 6

List box =

1
2
3
4
5
6


Ideally I would like it to say "table 1" ... etc but that is something I
can
sort out later
 
P

Phil

Sorted it, I already had a table in my database that was a list of numbers, I
set this as the row source and then limited the listbox to be = or < the
textbox value, there may be an easier way but it works, also I concatenated
the number with "Table" to give me Table 1 etc as the visible selector in the
textbox

Thanks

Phil

Phil said:
Hi Allen

Sorry, it is my useless explanation, I am trying to build a seat planner
onto my existing events planner.

The textbox Nooftables refers to the number of tables at the venue, I
wanted to create a listbox with a list of the tables so I can select a table
and see who is on that table (in another listbox). I am just struggling to
populate the Listbox, I need a list of tables

e.g No of tables available = 6

List Box shows

1
2
3
4
5
6

I can then select the table and assign people to that table, or veiw the table

By the way your code worked perfectly first time!

Thanks

Phil

Allen Browne said:
Set the Row Source of the list box to:

SELECT MsysObjects.Name FROM MsysObjects
WHERE (([Type] = 1)
AND ([Name] Not Like "~*")
AND ([Name] Not Like "MSys*"))
ORDER BY MsysObjects.Name;

Incldue types 6 and 4 for linked tables and ODBC linked tables respectively.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.
Phil said:
How can I fill a list box with numbers, I have a textbox [Nooftable] wher
I
enter the number of tables, I would then like the listbox to have a list
of
the tables

e.g

textbox = 6

List box =

1
2
3
4
5
6


Ideally I would like it to say "table 1" ... etc but that is something I
can
sort out later
 
L

Lutz Uhlmann

Dim nTableCount as Integer, i as Integer
Dim sTmp as String, sListSrc as String

nTableCount = 6 'Count of tables in list
i = 0

Do Until i>nTableCount
i = i+1
sTmp = "'Table " & i & "';"
sListSrc = sListSrc & sTmp
Loop

Me.lstTables.RowSource = sListSrc
 
P

Phil

Thank you, there is always a better solution than the one I end up with

Thanks

Phil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top