PDA

Click to See Complete Forum and Search --> : Using Listboxes


Gimpster
Nov 8th, 1999, 03:55 AM
I have a listbox that is filled with a list of tables from a database. The list changes frequently. I need to be able to take a table that the user selects in the listbox and use it to perform other operations, such as deleting the table. How can I do this, since I can't use a Select Case statement???

------------------
Ryan
corneslen@hotmail.com
ICQ# 47799046

Aaron Young
Nov 8th, 1999, 04:01 AM
The Name of the Table the User Selects will be Held in the Text Property which is the Default Property for a Listbox, eg.

oRs = oDB.OpenRecordSet("SELECT * FROM " & List1, dbOpenforwardOnly) 'Select All Records From Table Selected in List1

------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net

Gimpster
Nov 8th, 1999, 04:22 AM
Ok, that will work for opening the table, but if I just need the name that is selected in the listbox, then how would I go about extracting that from VB? Would that just be in the listbox.text property? Is that what you meant by the first part of your reply? Thanks.

------------------
Ryan
corneslen@hotmail.com
ICQ# 47799046

Gimpster
Nov 8th, 1999, 04:47 AM
What I need to be able to do is use the listbox to open another form (say the form name is "frmCustomer"), that has the same name as the table that is selected (when the table name is "Customer"). But I can't figure out how to get the name in the listbox into a .show command. Can you enlighten me? I hope you can. Or possibly show me another way I can accomplish the same thing. If I need to rename the form in order to make it work, that's no big deal. Thanks.

------------------
Ryan
corneslen@hotmail.com
ICQ# 47799046

Serge
Nov 8th, 1999, 06:14 PM
Create a global variable in the module:


Public g_strTableName As String


Then put this on List1_Click event:
strTableName = List1.List(List1.ListIndex)

Then on the frmCustomers Form_Load event use this variable:

strSQL = "Select * From " & g_strTableName

Regards,


------------------

Serge

Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819




[This message has been edited by Serge (edited 11-09-1999).]