Running this code the application throws an Error 91: "Object Variable or With block Variable not set" when it hits the "Set rst to..." line.
Viewing strSQL in the Immediate Window, "Me.cboDonor2Report.Column(0)" is resolving to a valid ID value.
If I create a new query and copy the strSQL contents into the definition and Run the query it I get what I expect. What could be causing this??
Viewing strSQL in the Immediate Window, "Me.cboDonor2Report.Column(0)" is resolving to a valid ID value.
If I create a new query and copy the strSQL contents into the definition and Run the query it I get what I expect. What could be causing this??
Code:
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
strSQL = "SELECT tblIndividual.ID, tblIndividual.Addressee, tblIndividual.Env, tblFamily.Address, " & _
"RTrim(tblFamily.City) & ', ' & tblFamily.State & ' ' & tblFamily.Zip AS TheFCSZ, tblIndivAdr.Address, " & _
"RTrim(tblIndivAdr.City) & ', ' & tblIndivAdr.State & ' ' & tblIndivAdr.Zip AS TheICSZ " & _
"FROM (tblIndividual LEFT JOIN tblIndivAdr ON tblIndividual.ID = tblIndivAdr.ID) INNER JOIN tblFamily ON tblIndividual.FamilyID = tblFamily.ID " & _
"WHERE tblIndividual.ID = " & Me.cboDonor2Report.Column(0)
Set rst = dbs.OpenRecordset(strSQL)