I have the following SQL Query where I’m collecting data from three tables from my SQL database. I’m using version 2005 SQL server.
Code: Select all
strSQL = "SELECT Main.BilledDate, ItemDetail.ItemDescription,ctInfo.Sex FROM ((Main INNER JOIN ItemDetail On Main.BillID =" & _
"ItemDetail.BillNo)INNER JOIN ctInfo On Main.PersonID = ctInfo.ctIdxNo) WHERE FORMAT (Main.BilledDate,'dd-MM-yyyy')= " & ws.Range("L8").Value
rst.Open strSQL, cnn, adOpenKeyset, adLockOptimistic, adCmdText
ws.Range("E18").CopyFromRecordset rst
rst.Close