dbs.OpenRecordset(strSQL) problem

sjr1917

Registered User.
Local time
Today, 10:31
Joined
Dec 11, 2012
Messages
47
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??

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)
 
First try adding
Set dbs = CurrentDB
before the Set rs statement
 
Of Course!! Thanks.
I knew I should just walk away and come back later... too many hours behind a keyboard. :banghead:
 

Users who are viewing this thread

Back
Top Bottom