Hello Everyone,
I have the following code:
I have VBA For Applications, Microsoft Excel 11.0 Object Library, OLE Automation, Microsoft Active X Data Objects 2.5 Library check in Tools, References. The Active X Data Objects 2.5 Library should reference Jet 4.0. My code keeps stoping on this line:
What am I forgetting here? I had it working in another spreadsheet with the same references. The worksheet is not protected.
TIA
Kurt
I have the following code:
Code:
Sub command_parameters()
Dim conn As New Connection
Dim rec As New Recordset
Dim comm As Command
Dim ws As Worksheet
Dim countryname$
Set ws = ThisWorkbook.Worksheets("command")
conn.Open "Provider=microsoft.jet.oledb.4.0;" + _
"Data Source=" + ThisWorkbook.Path + "C:\NWind.mbd;"
Set comm.ActiveConnection = conn
comm.CommandText = _
"SELECT companyname FROM Customers WHERE Country = ?"
countryname = InputBox("Please input the name of a country " & _
"(for example, 'germany').")
rec.Open comm
ws.[a1].CopyFromRecordset rec
rec.Close: conn.Close
End Sub
I have VBA For Applications, Microsoft Excel 11.0 Object Library, OLE Automation, Microsoft Active X Data Objects 2.5 Library check in Tools, References. The Active X Data Objects 2.5 Library should reference Jet 4.0. My code keeps stoping on this line:
Code:
conn.Open "Provider=microsoft.jet.oledb.4.0;" + _
"Data Source=" + ThisWorkbook.Path + "C:\NWind.mbd;"
What am I forgetting here? I had it working in another spreadsheet with the same references. The worksheet is not protected.
TIA
Kurt