OTWarrior
01-05-2017, 09:02 AM
Hello
[Using Access 2016]
I am tying to develop a form, that will import data from Excel, and create dynamic queries based on the imported information.Each excel spreadsheet can have different values, including number of columns and fieldnames.
I have managed to work out how to import an excel spreadsheet to access and save as a table, along with changing the recordsource for the form to match the table.
I now need to have a generate button, to display each of the fields (so you can toggle them on/off) and if selected, allow the user to select from within that fields dataset from a dropdown.
A bit of a tall order I know.
Say I have 5 comboboxes and their labels.
How can I populate Label1 with the first fieldname from the table, and populate the combolist itself with unique values from the first field.
Then do this for the second field from the table and second combo/label respectively?
This is what I have so far, but it errors on comboLIST.Name, saying "error 91, object with or variable not set"
Private Sub cmdPopulate_Click()
Dim comboLIST As ComboBox
For i = 1 To 25 ' will need to be dynamic later
Dim strSQL As String
comboLIST.Name = "Combo" & i
comboLIST.RowSourceType = "Table/Query"
comboLIST.RowSource = "Select [Field & " & i & "] FROM " & LabelFile.Caption
Next i
End Sub
[Using Access 2016]
I am tying to develop a form, that will import data from Excel, and create dynamic queries based on the imported information.Each excel spreadsheet can have different values, including number of columns and fieldnames.
I have managed to work out how to import an excel spreadsheet to access and save as a table, along with changing the recordsource for the form to match the table.
I now need to have a generate button, to display each of the fields (so you can toggle them on/off) and if selected, allow the user to select from within that fields dataset from a dropdown.
A bit of a tall order I know.
Say I have 5 comboboxes and their labels.
How can I populate Label1 with the first fieldname from the table, and populate the combolist itself with unique values from the first field.
Then do this for the second field from the table and second combo/label respectively?
This is what I have so far, but it errors on comboLIST.Name, saying "error 91, object with or variable not set"
Private Sub cmdPopulate_Click()
Dim comboLIST As ComboBox
For i = 1 To 25 ' will need to be dynamic later
Dim strSQL As String
comboLIST.Name = "Combo" & i
comboLIST.RowSourceType = "Table/Query"
comboLIST.RowSource = "Select [Field & " & i & "] FROM " & LabelFile.Caption
Next i
End Sub