Set objMyConn = OpenAccessDB("Z:\[DBNAME].mdb")
Set rstClient = CreateObject("ADODB.Recordset")
strSQL = "SELECT tbl001_Clients.CompanyID, tbl001_CompanyHeader.CompanyName " & "FROM tbl001_Clients " & _
"INNER JOIN tbl001_CompanyHeader " & "ON tbl001_Clients.CompanyID = tbl001_CompanyHeader.CompanyID;"
Debug.Print strSQL
If objMyConn.State = adStateOpen Then
MsgBox ("You are in")
End If
rstClient.Open strSQL, objMyConn, , adLockReadOnly
If rstClient.State = adStateOpen Then
With rstClient
.MoveFirst
If (.State = adStateOpen) And (Not (.EOF)) Then
Do Until .EOF
strName = .Fields("CompanyName")
Debug.Print strName
.MoveNext
Loop
End If
End With
End If
|