H
hans
I use the following code.
Sub ADOImportFromAccessTable(DBFullName As String, TableName As String, TargetRange As Range)
' Example: ADOImportFromAccessTable "C:\FolderName\DataBaseName.mdb", _
"TableName", Range("C1")
Dim cn As ADODB.Connection, rs As ADODB.Recordset, intColIndex As Integer
Set TargetRange = TargetRange.Cells(1, 1)
target = TargetRange.Cells(1, 1)
' open the database
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & DBFullName & ";"
Set rs = New ADODB.Recordset
With rs
.Open "SELECT * FROM Postcode" & " WHERE [Postcode] = " & TargetRange, cn, , , adCmdText
waarde = rs.Fields(intColIndex).Value
TargetRange.Offset(0, 1) = waarde
I get the error
syntaxerror operator missing.
Can someone help
Thanks Hans
Sub ADOImportFromAccessTable(DBFullName As String, TableName As String, TargetRange As Range)
' Example: ADOImportFromAccessTable "C:\FolderName\DataBaseName.mdb", _
"TableName", Range("C1")
Dim cn As ADODB.Connection, rs As ADODB.Recordset, intColIndex As Integer
Set TargetRange = TargetRange.Cells(1, 1)
target = TargetRange.Cells(1, 1)
' open the database
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & DBFullName & ";"
Set rs = New ADODB.Recordset
With rs
.Open "SELECT * FROM Postcode" & " WHERE [Postcode] = " & TargetRange, cn, , , adCmdText
waarde = rs.Fields(intColIndex).Value
TargetRange.Offset(0, 1) = waarde
I get the error
syntaxerror operator missing.
Can someone help
Thanks Hans