I am trying to figure out how to use Excel as an interactive front end to MySQL. It will be my first VBA experience with a database.
My scenario is I want to enter an order number into one cell, and upon completing the input, I want an SQL query to be ran, like SELECT field1, field2 FROM table WHERE order_number = ?
, and then display the return result of field1
in a cell. I may use field2
in other cells.
I see there is some code here that may be useful, but I don't know where to enter that code, and how to make that code work after I enter an order number into the cell. I have already made an ODBC Driver connection to where I am able to connect to a database using Excel Database functions. I don't yet know how to use VBA do make a database connection or run interactive queries.
Can you help get me to the point where I can enter an order number in one cell, and see field1
show up in another cell, where field1
will be a value from an SQL query, like the above?