Results 1 to 2 of 2
  1. #1
    silverspr is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2011
    Posts
    19

    Output form recordset clone to word

    Hi everyone, I have this code on a cmdButton on a form:

    The code works as designed the first time the cmd button is clicked. There after the word document opens as blank. I thought the form recordset was "active" for the entire time the form was visible. Requerying the form didn't work creating an error no current record. How do I get the code tor run properly more than once? thanks


    Public Sub WordEx()


    Set WordApp = New Word.Application
    WordApp.Documents.Add
    Set doc = WordApp.ActiveDocument
    Set sel = WordApp.Selection
    WordApp.Visible = True


    End Sub






    Private Sub cmdCopy_Click()
    'On Error GoTo Err_cmdCopy_Click




    Dim db As DAO.Database
    Set db = CurrentDb()
    Dim rs As DAO.Recordset
    Dim fld As DAO.Field, strSQL As String
    Set rs = Screen.ActiveForm.RecordsetClone
    'Me.Requery
    Select Case Me.Frame2
    Case Is = 1
    Set fld = rs.Fields(4)
    Case Is = 2
    Set fld = rs.Fields(5)
    End Select




    WordEx


    Do Until rs.EOF


    sel.TypeText Text:=fld.Value & vbCrLf & vbCrLf


    rs.MoveNext


    Loop




    Exit_cmdCopy_Click:
    Exit Sub


    Err_cmdCopy_Click:
    MsgBox Err.Description


    Resume Exit_cmdCopy_Click

    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Maybe should explicitly reference the form by name or Me alias, not by ActiveForm.

    Have you step debugged?
    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.

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

Similar Threads

  1. Replies: 7
    Last Post: 09-28-2023, 08:41 AM
  2. Replies: 7
    Last Post: 01-22-2013, 09:44 PM
  3. RecordSet Clone Problem with code
    By rlsublime in forum Programming
    Replies: 8
    Last Post: 06-21-2012, 11:56 AM
  4. Replies: 0
    Last Post: 03-07-2012, 08:10 AM
  5. multiple combo boxes recordset clone
    By trigirl67 in forum Forms
    Replies: 1
    Last Post: 01-30-2012, 02:32 PM

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