Creating SQL query taking the field name from a text box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jahansam
    New Member
    • May 2015
    • 2

    Creating SQL query taking the field name from a text box

    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","tra nsaction". 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),t ransaction from bank where (text1.value) = (text2.value)
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32661

    #2
    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?

    Comment

    • jahansam
      New Member
      • May 2015
      • 2

      #3
      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.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32661

        #4
        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.

        Comment

        Working...