Update Table by Editing SQL Variables in Query with VBA

localsearchguy

New Member
Joined
Feb 26, 2010
Messages
2
I've got a good start, but i'm not that fluent in VBA, so I could really use a hand. I'm trying to pass variables from VBA to a query that is running against a MySQL database. here is the code so far...

Code:
Sub QueryData_Update()
Dim Client As Variant
Set Sheets("ReportUS") = report
Set Sheets("QueryData").ListObject("Table_llmperf9") = QueryData
Set Sheets("ActionsData") = ActionsData
Set Sheets("DirectionData") = DirectionData
Set Sheets("ImpressionData") = ImpressionData
Client = report.Range("C3").Text
With QueryData(Connection:=("ODBC;DSN=perfllm;UID=root;PWD=password;DATABASE=database;OPTION=0;PORT=3306;SERVER=localhost"), Destination:=Sheets("QueryData"))
        .CommandText = Array("SELECT * FROM `querydata_view` Where Business Name =" & Client)
        .Name = "QueryData_View"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = 2
        .SavePassword = True
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .PreserveColumnInfo = True
        .Refresh BackgroundQuery:=False
    End With
End Sub

I'm questionabout about line 4 and almost positive line 9 is wrong...
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Forum statistics

Threads
1,223,924
Messages
6,175,415
Members
452,640
Latest member
steveridge

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top