JimS
08-24-2005, 06:37 AM
I have created a number of tables that contain the names of the counties, for each state of the US. I’ve named the tables CountiesAL, CountiesAK, etc. I’ve added these tables to my globals.
Here is what I want to happen, you pick a State from ComboBox1. Say you pick Alabama the Data for Alabama is AL (selected_data = “AL”)
Now I want to automatically fill ComboBox2 with the proper counties from that State, drawn from the table called CountiesAL
I get the table name by concatenating “Counties”..selected_data
The problem is when I try to query the table, instead of a table, it sees just the string.
My question is how do I address a table whose name I know only as a variable (string)?
Here is a sample of the code I’m trying
-- Gets the index of the selected item.
selected_index = ComboBox.GetSelected("ComboBox1");
-- Make sure an item is selected.
if (selected_index ~= -1) then
-- Reset The ComboBox of County names
ComboBox.ResetContent("ComboBox2");
selected_data = ComboBox.GetItemData("ComboBox1", selected_index);
for j, k in ("Counties"..selected_data ) do
result = ComboBox.AddItem("ComboBox2", k);
end
end
Here is what I want to happen, you pick a State from ComboBox1. Say you pick Alabama the Data for Alabama is AL (selected_data = “AL”)
Now I want to automatically fill ComboBox2 with the proper counties from that State, drawn from the table called CountiesAL
I get the table name by concatenating “Counties”..selected_data
The problem is when I try to query the table, instead of a table, it sees just the string.
My question is how do I address a table whose name I know only as a variable (string)?
Here is a sample of the code I’m trying
-- Gets the index of the selected item.
selected_index = ComboBox.GetSelected("ComboBox1");
-- Make sure an item is selected.
if (selected_index ~= -1) then
-- Reset The ComboBox of County names
ComboBox.ResetContent("ComboBox2");
selected_data = ComboBox.GetItemData("ComboBox1", selected_index);
for j, k in ("Counties"..selected_data ) do
result = ComboBox.AddItem("ComboBox2", k);
end
end