Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    Ganymede is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    64

    Error using Recordset2, SavetoFile or Field2

    EDIT: SEE PAGE 2 FOR SOLUTION


    Is there some other reference I need to enable to use DAO.Recordset2? Here's what I current have enabled:

    Visual Basic for Applications
    Microsoft Access 12.0 Object Library


    OLE Automation
    Microsoft DAO 3.6 Object Library
    Microsoft Calendar Control 2007
    Microsoft ActiveX Data Objects 6.0 Library
    Microsoft Outlook 12.0 Object Library
    Microsoft Visio Viewer 12.0 Library
    Microsoft ADO Ext. 6.0 for DLL and Security

    Thanks
    Last edited by Ganymede; 06-04-2012 at 11:43 AM.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    What do you mean by .Recordset2? The DAO.Property is just .Recordset.

  3. #3
    Ganymede is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    64
    Quote Originally Posted by RuralGuy View Post
    What do you mean by .Recordset2? The DAO.Property is just .Recordset.
    That's what I thought. Then I saw the code exhibited here and the microsoft's explanation here. Unfortunately, microsoft doesn't explain very well.

    But even when I remove the 2 and try going with recordset, I get an error for SaveToFile (sorry wasn't mentioned in OP. It's a new development). So for some reason I seem to be missing some DAO objects.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The code you are referring to in that link will *not* compile. It will get the same error you are getting. The code implies that .SaveToFile is a member of the .Fields collection and it is not. Sorry. I'll see if June7 wants to join in here.

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Boy oh boy oh boy. It looks like there may be something new in Access called Recordset2. I've pinged June7 to see if she will drop by and help here.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    It looks like it should be the Field2 property rather than the Fields property.
    http://msdn.microsoft.com/en-us/libr...1(v=office.12)

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    It looks like you have more than one thread going on this topic and June7 is trying to help. Don't post any further in either thread until you hear from June7 or me. It looks like .Recordset2 is for dealing with the "new" attachment type fields. June7 is aware of this thread.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Code in the referenced thread is not mine. I just guided OP in adapting it. Maybe tobydobo can clarify how got it to work?

    I have never used Recordset2. I don't use Attachment field type. I probably did test the code but have since discarded.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    @June7: Thanks!

    @Ganymede: Are you trying to work with an Attachment Field?

  10. #10
    Ganymede is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    64
    Quote Originally Posted by RuralGuy View Post
    @June7: Thanks!

    @Ganymede: Are you trying to work with an Attachment Field?
    Yes.

    My understanding was that the code saves the file in your attachment field to a temporary folder. Then you attach the file to an email using a separate code. That's basically what I'm hoping to accomplish.

    I'm installing the MS Office 2010 trial version at home to see if I can't get it working there. It may be that Access 2007 doesn't have what I'm looking for.

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    The attachment type was introduced with 2007 so the code should work. Tobydobo shows using 2007.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    Ganymede is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    64
    Quote Originally Posted by June7 View Post
    The attachment type was introduced with 2007 so the code should work. Tobydobo shows using 2007.
    Then the only explanation I can think of is that I haven't enabled the proper references.

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    I just tested the procedure. The only library reference I had to set was for Outlook. There is one library reference you don't show. It is one of the 4 references that Access sets by default with new project. Compile does error if I remove it:
    Microsoft Office 12.0 Access database engine Object Library

    I put code in a general module instead of behind a form and used this code to open parent recordset:

    Set rsParent = db.OpenRecordset("SELECT fieldname FROM tablename", dbOpenDynaset)

    Then I had to change rsChild to refer to my attachment fieldname.

    Set rsChild = rsParent.Fields("fieldname").Value

    Also changed code for my folder pathing.

    Code worked perfectly. Tested with Access 2007.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  14. #14
    Ganymede is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    64
    Quote Originally Posted by June7 View Post
    I just tested the procedure. The only library reference I had to set was for Outlook.

    I put code in a general module instead of behind a form and used this code to open parent recordset:

    Set rsParent = db.OpenRecordset("SELECT fieldname FROM tablename", dbOpenDynaset)

    Then I had to change rsChild to refer to my attachment fieldname.

    Set rsChild = rsParent.Fields("fieldname").Value

    Also changed code for my folder pathing.

    Code worked perfectly. Tested with Access 2007.
    Thank you. I'll give that a shot.

  15. #15
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Oops! I was editing my post as you posted. Review mine again.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. disabling an enabled button that has been clicked.
    By aaron47 in forum Programming
    Replies: 3
    Last Post: 08-26-2011, 09:49 AM
  2. Application-defined or object-defined error
    By hawkins in forum Access
    Replies: 6
    Last Post: 07-01-2011, 01:57 PM
  3. Enabled = False
    By Juan4412 in forum Forms
    Replies: 2
    Last Post: 04-19-2011, 06:05 PM
  4. Error: "User-defined type not defined"
    By mastromb in forum Programming
    Replies: 10
    Last Post: 01-08-2010, 02:57 PM
  5. Replies: 4
    Last Post: 09-10-2009, 03:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums