Results 1 to 2 of 2
  1. #1
    southernx50 is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    2

    get data from one recordset with the field name being in another recordset

    I'm not sure where to post this so I apologize in advance if it is in the wrong forum. I have a table that associates Word Bookmarks with the Field Names in the main Sales data table. The idea was to allow the end users to come up with their own reports in word using bookmarks and then associate the bookmarks with the field names in the Sales table. Then they could press a button and "by magic" the program would produce their new report nicely filled in with the correct data from the sales table.

    The problem is that I can't figure out how to refer to the field name in the sales table (rstData) that is stored in the associations table (rstBookmark). Below is my latest attempt that failed miserably.

    rstData.MoveFirst
    Dim fldName As DAO.Field
    Do While Not rstData.EOF 'stepping through the Sales records they selected
    'fill the template table
    rstBookmark.MoveFirst
    Do While Not rstBookmark.EOF
    Set fldName = rstBookmark!TableFieldName
    'Update the bookmark with the data in rstData
    'rstBookmark!WordBookmarkName has the name of the Bookmark
    'rstBookmark!TableFieldName has the name of the Field that is in rstData
    UpdateBookmark oDoc_TempTemplate, rstBookmark!WordBookmarkName, rstData!fldName


    rstBookmark.MoveNext
    Loop
    'All the data has been written to the table
    'copy the TempTemplate table
    oDoc_TempTemplate.Tables(1).Range.Copy
    'paste it into the Final Document
    oSel_FinalDoc.Range.Paste

    'move to the next Property
    rstData.MoveNext
    Loop

  2. #2
    southernx50 is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    2
    solved.

    rstData.Fields(rstBookmark!TableFieldName)

Please reply to this thread with any new information or opinions.

Similar Threads

  1. This Recordset Is Not Updateable
    By botts121 in forum Access
    Replies: 1
    Last Post: 11-11-2009, 05:43 PM
  2. The Recordset is not updatable
    By bullet_proof302 in forum Access
    Replies: 2
    Last Post: 11-07-2009, 12:13 PM
  3. select records in recordset
    By sksriharsha in forum Programming
    Replies: 3
    Last Post: 09-05-2009, 11:40 AM
  4. Sorting data in ADO Recordset
    By martinjamesward in forum Programming
    Replies: 1
    Last Post: 08-28-2009, 05:38 AM
  5. ADO.Recordset - Write
    By Marvin in forum Programming
    Replies: 0
    Last Post: 07-17-2009, 07:56 AM

Tags for this Thread

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