ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   getting table name from a text box query (https://www.excelbanter.com/excel-programming/399800-getting-table-name-text-box-query.html)

Kamran

getting table name from a text box query
 
I have succsessfully made a datebase connection using DAO. now I want to get
data from a specific table of database using table name written in combobox.
what will be a quaery for retriving table name from a combobox or textbox.

example:

rs=db.openrecordset("select * from combobox1.text)"
but its not working

Nigel[_2_]

getting table name from a text box query
 
Probably because you are not referencing the control explicitly. That is
the ComboBox or TextBox, if these are on the worksheet refer to them as

Sheets("SheetName").ComboBox1.Value

or UserForm

UserForm1.ComboBox1.Value

I personally would store the control value to variable and refer to that,
also trim the value in case there are spurious spaces in the string!

--

Regards,
Nigel




"Kamran" wrote in message
...
I have succsessfully made a datebase connection using DAO. now I want to
get
data from a specific table of database using table name written in
combobox.
what will be a quaery for retriving table name from a combobox or textbox.

example:

rs=db.openrecordset("select * from combobox1.text)"
but its not working




All times are GMT +1. The time now is 01:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com