Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recordset clone giving me errors

Status
Not open for further replies.

Moss100

Technical User
Aug 10, 2004
586
GB
Hello,

When I run the code below it errors - I have tried for sometime to see where I am going wrong - help much appreciated.

Thanks Mark

Code:
'Add Attachments
    Dim db As DAO.Database
    Dim rstAttachments As DAO.Recordset
    Dim rstRecordsToSend As DAO.Recordset
      
      Set db = CurrentDb()
      Set rstRecordsToSend = Me.RecordsetClone
      Set rstAttachments = "SELECT [InvChk_Scan_Path] FROM [rstRecordsToSend] WHERE [InvChk_Select_Invoice] = True"
 
You can't reference a recordset inside an SQL statement like that. The FROM must be a table or query. There are lots of tasks you can perform on recordsets such as filtering, looping through etc.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Thanks for that - I will do some further reading - much appreciated Mark
 
There are ways to get the underlying SQL statement of a recordset, not by "RecordsetClone", but by recordset.CopyQueryDef.SQL.
That being said: since you want to use a recordset object anyway, why not set a filter?

"Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family." (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top