Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Oct 2001
    Location
    Newport, Gwent, Wales
    Posts
    257
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Adding record to a temprorary recordset in code (Access 2k)

    Dear All

    I'm trying to get a procedure up and running that will create a number of Word Documents and then attach them to an Outlook email. Now I've got my head around the automation for OutLook and Word, the problem is that there could any number of Word Documents from 0 to 20 plus.

    I'm thinking that using a temporary recordset in code might be a nice solution to this, but I'm unsure as to exactly how to go about it! So, what should I be looking up in the help files to get me moving? I can define recordsets (Dim Rst as DAO.Recordset), I can populate the record set from a SQL string, what I want to do is to add a new record to the record set each time I create a document. The document name will be held in a string variable temporarily. So, what do I need to do to get that variable value into a temporary recordset?

    Hope this makes sense.

    Ian

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Adding record to a temprorary recordset in code (Access 2k)

    Are you talking about a recordset entirely in code? I wouldn't use DAO for that. ADO on the other hand allows you to create recordsets entirely in code and even persist them to a file in either xml or access tablegram format. I have a demo of persisted recordsets at http://www.rogersaccesslibrary.com/OtherLi...Foust,Charlotte that you might take a look at.
    Charlotte

  3. #3
    3 Star Lounger
    Join Date
    Oct 2001
    Location
    Newport, Gwent, Wales
    Posts
    257
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding record to a temprorary recordset in code (Access 2k)

    Well, the demo looks nice, however, it's taken me a while to gain any level of confidence in DAO, so moving to ADO is not something I'm in a hurry to do...

    I don't want to keep the data any longer than the code is running for, if I can't do this purely in VBA, can I create a new table, populate it with the file name, then delete it after I've used the data? Or is this going to be more difficult than learning the dark arts of ADO???

    Thanks

    Ian

  4. #4
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding record to a temprorary recordset in code (Access 2k)

    If you only want to keep the data when the code is running, why don't you put the names in an array instead of writing them to a temp table ?
    Francois

  5. #5
    3 Star Lounger
    Join Date
    Oct 2001
    Location
    Newport, Gwent, Wales
    Posts
    257
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding record to a temprorary recordset in code (Access 2k)

    Arrays look like they might be my answer, now how would I refer to the data in the array? With a recordset I can use RST!ItemName and loop through it using the MoveNext instruction. Looking at the Using Arrays help section there are not hints on how to do the same, getting data in appears to be easy enough even for me to manage [img]/forums/images/smilies/smile.gif[/img]

    I'll keep reading, but if there's any easy way, send it my way please [img]/forums/images/smilies/biggrin.gif[/img]

    Thanks

    Ian

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Adding record to a temprorary recordset in code (Access 2k)

    Arrays use purely numeric indexes. Collections, however, can use a named key, so you might consider trying a collection, which is populated with an AddItem method.
    Charlotte

  7. #7
    New Lounger
    Join Date
    Sep 2004
    Location
    ST Albabs, Hertfordshire, England
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding record to a temprorary recordset in code (Access 2k)

    I had a similar task to perform but approached it in a different manner. In code I created(or emptied) a temp folder on the c: drive then once each document had been created through automation I copied it there. Then performed a simple for each loop to attach any docs in the folder to the email.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •