View Full Version : VBA Data from an access database using a variable

05-06-2015, 11:06 PM
I have an access database that holds the setups for a number of different tests. Each column header is in the format test type and file name. i have a form with comboboxes the selected data from the combo boxes selects what column is needed in the database.

so for instance i have a column in the database named "Test1: File1"
combobox1 has a value when selected of "Test1"
combobox2 has a value when selected of "File1"

i create a new recordset called rs

is there a way of getting the data from the column using the combobox values like this

rs![Combobox1.value & ": " & Combobox2.value]

instead of using

rs![Test1: File1]

I get an errror when using the combobox.values method

run-time error '3265':
Item cannot be found in the collection corresponding to the requested name or ordinal

05-07-2015, 12:51 AM
rs(Combobox1.value & ": " & Combobox2.value).value

05-07-2015, 02:31 AM
Thanks works great