justin.cress
New Member
- Joined
- Oct 3, 2011
- Messages
- 1
I've set up an oracle db with ms sql, and have been experimenting with using VBA to change the sql statement and refresh, (new to VBA)
here's what I have so far (and it works)
Questions:
1. Hard coding the 'range' and table names into the select seems dubious. How do I achieve the desired effect without hard coding?
2. What if there's more than one query table on the sheet?
here's what I have so far (and it works)
Code:
Private Sub Submit_Click()
Set qry = QTable.ListObjects(1).QueryTable
qry.CommandText = form.SQLText.Text
Sheets("Qtable").Select
Sheets("Qtable").Range("A2").Select
Selection.ListObject.QueryTable.Refresh
End Sub
Questions:
1. Hard coding the 'range' and table names into the select seems dubious. How do I achieve the desired effect without hard coding?
2. What if there's more than one query table on the sheet?