By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,453 Members | 937 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,453 IT Pros & Developers. It's quick & easy.

Creating SQL query taking the field name from a text box

P: 2
Hi, in MS Access I want to create a SQL query where field name can be taken from a text box or combobox. For example, I have a table name "bank" and it has fields "Customer_id","Cust_name","transaction". I want to display all transactions of customer "John". So I have two text boxes to provide the field name and the customer name. I want to make an SQL query to display the results but I don't want to provide the field/column name directly to the SQL command instead using text box. Can anyone help me please?

I don't want to write : SELECT Cust_name, transaction from bank where Cust_name = "John"

I want like : SELECT (text1.value),transaction from bank where (text1.value) = (text2.value)
May 7 '15 #1
Share this Question
Share on Google+
3 Replies

Expert Mod 15k+
P: 31,768
SQL commands are basically strings.

Do you need specific instructions on how to work with strings or does that give you enough of a clue to get you going?
May 7 '15 #2

P: 2
Well, I want to see that the SQL gives me the records of transaction matching with the name "John". So, later I can use other field name without changing the SQL command.
May 7 '15 #3

Expert Mod 15k+
P: 31,768
I expect you do, but that doesn't answer my question. I'm ready to help but we need to converse sensibly for that to happen.
May 8 '15 #4

Post your reply

Sign in to post your reply or Sign up for a free account.