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

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Adding record to a temprorary recordset in code (Access 2k)

    Author
    Topic
    #409385

    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

    Viewing 3 reply threads
    Author
    Replies
    • #872009

      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%5B/url%5D that you might take a look at.

      • #872067

        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

      • #872068

        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

        • #872081

          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 ?

          • #872119

            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

            I’ll keep reading, but if there’s any easy way, send it my way please

            Thanks

            Ian

            • #872483

              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.

            • #872484

              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.

          • #872120

            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

            I’ll keep reading, but if there’s any easy way, send it my way please

            Thanks

            Ian

        • #872082

          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 ?

    • #872010

      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%5B/url%5D that you might take a look at.

    • #872541

      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.

    • #872542

      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.

    Viewing 3 reply threads
    Reply To: Adding record to a temprorary recordset in code (Access 2k)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: