JumboCactuar
Well-known Member
- Joined
- Nov 16, 2016
- Messages
- 788
- Office Version
- 365
- Platform
- Windows
Hi,
cant figure out whats wrong here:
This Works with the following SQL string in cell P9
SELECT * From [DataSheet$] WHERE Region='UK'
But it fails with this, where the Region is in cell P7
SELECT * From [DataSheet$] WHERE Region='" & REGION1 & "'
The code completes without errors, though no data is output
Ive run through the code and it looks fine
(Ignore screenshots where it's calling SBADO I changed this)
Does anyone know what the problem is?
Appreciate any help
cant figure out whats wrong here:
This Works with the following SQL string in cell P9
SELECT * From [DataSheet$] WHERE Region='UK'
But it fails with this, where the Region is in cell P7
SELECT * From [DataSheet$] WHERE Region='" & REGION1 & "'
PHP:
Sub Test2()
Dim REGION1 As String, SQLSTR As String
REGION1 = Range("P7")
SQLSTR = Range("P9")
Call sbADO2(REGION1, SQLSTR)
End Sub
PHP:
Sub sbADO2(REGION1 As String, SQLSTR As String)
Dim sSQLQry As String
Dim ReturnArray
Dim Conn As New ADODB.Connection
Dim mrs As New ADODB.Recordset
Dim DBPath As String, sconnect As String
DBPath = ThisWorkbook.FullName
sconnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DBPath _
& ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"";"
Conn.Open sconnect
sSQLSting = SQLSTR
mrs.Open sSQLSting, Conn
ActiveSheet.Range("A2").CopyFromRecordset mrs
mrs.Close
Conn.Close
End Sub
The code completes without errors, though no data is output
Ive run through the code and it looks fine
(Ignore screenshots where it's calling SBADO I changed this)
Does anyone know what the problem is?
Appreciate any help
Last edited: