populating list box with fields name of a table

  • Thread starter Thread starter Nasir.Munir
  • Start date Start date
N

Nasir.Munir

I am trying to create a form which will have two list boxes. The first
list box will be populated with the table names(which I will get from
linked odbc). Once a user selects a table in the list, then the second
list box should display the fields of that particular table.
What I have done so far is:
1)created a form
2)added two list boxes
3)created a query to get the names of the table from sysobject table.
4)populated the first list box with the names of the table.
I am stuck here, as I dont know how to get the names of the column of
the table(just the names not the data). Also, how can I link the two
list boxes together ? If I go to the event builder(code part) and try
to use listbox2.value = listbox1.value or anything like this, I am
getting "no module found" error, and sometimes a message suggesting
that form name is misspelled.
I am new to access, can anyone help ?
I am using access 2000, and my OS is windows XP.
 
I am trying to create a form which will have two list boxes. The first
list box will be populated with the table names(which I will get from
linked odbc). Once a user selects a table in the list, then the second
list box should display the fields of that particular table.
What I have done so far is:
1)created a form
2)added two list boxes
3)created a query to get the names of the table from sysobject table.
4)populated the first list box with the names of the table.
I am stuck here, as I dont know how to get the names of the column of
the table(just the names not the data). Also, how can I link the two
list boxes together ? If I go to the event builder(code part) and try
to use listbox2.value = listbox1.value or anything like this, I am
getting "no module found" error, and sometimes a message suggesting
that form name is misspelled.
I am new to access, can anyone help ?
I am using access 2000, and my OS is windows XP.


To display a list of the fields in a table, you can just set
listbox2's RowSourceType property to Field List

You need to use a little code to "connect" the list boxes.
Add this kind of thing to listbox1's AfterUpdate event
procedure:

Me.listbox2.RowSource = Me.listbox1
 
I am trying to create a form which will have two list boxes. The first
list box will be populated with the table names(which I will get from
linked odbc). Once a user selects a table in the list, then the second
list box should display the fields of that particular table.
What I have done so far is:
1)created a form
2)added two list boxes
3)created a query to get the names of the table from sysobject table.
4)populated the first list box with the names of the table.
I am stuck here, as I dont know how to get the names of the column of
the table(just the names not the data). Also, how can I link the two
list boxes together ? If I go to the event builder(code part) and try
to use listbox2.value = listbox1.value or anything like this, I am
getting "no module found" error, and sometimes a message suggesting
that form name is misspelled.
I am new to access, can anyone help ?
I am using access 2000, and my OS is windows XP.

Assuming you are getting the names of the tables in ListBox1, code the
ListBox1 Click event:

ListBox2.RowSource = Me.ListBox1

In ListBox2, set the RowsourceType property to Field List.
Leave the Rowsource blank.

A selection of a table in ListBox1 will load that table's fields into
ListBox2.
 
Back
Top