Struck a snag with this
I'm being told tblMain4 can't be found and it's because (I think)
With CurrentDb.CreateQueryDef("", sql)
is wrong. It isn't the currentDB but the one I've opened the connection to. How would I change that line ?
Code:
Set r = CurrentDb.OpenRecordset(sq2$)
cnn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & "\\JOHN\Desktop\Build11.mdb"
cnn.Open
r.MoveFirst
Do
sql$ = "SELECT AComment, Title FROM tblMain4"
sql$ = sql$ & " WHERE Title = p0;"
' sql$ = sql$ & Chr$(34) & r!TTitle & Chr$(34)
With CurrentDb.CreateQueryDef("", sql)
.Parameters("p0") = r!TTitle
End With
With rx
.Open sql$, cnn, adOpenStatic, adLockReadOnly
' Do Stuff
.Close
End With
r.MoveNext
Loop Until r.EOF
cnn.Close
r.Close
Set r = Nothing
With CurrentDb.CreateQueryDef("", sql)
is wrong. It isn't the currentDB but the one I've opened the connection to. How would I change that line ?