Results 1 to 2 of 2
  1. #1
    fcbuek is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    6

    Export of subforms

    Hi, I have a question whether it is possible to export data from my form (using the Export button) filtered data from my subform (e.g. if I used a filter in one of the tables).



    Code:
    Private Sub Polecenie2_Click()
    On Error GoTo errHandler
    Dim qdf As QueryDef
    DoCmd.DeleteObject acQuery, "qryTemp"
    Set qdf = CurrentDb.CreateQueryDef("qryTemp", Me.Tabela2.Form.RecordSource)
    DoCmd.OutputTo acOutputQuery, "qryTemp", acFormatXLS, "C:\Users\dzajo\Desktop\Nowy folder\Tbl1XLS.xls", True
    exitHandler:
    Exit Sub
    
    errHandler:
    If Err.Number = 7874 Then
    Resume Next
    Else
    MsgBox Err.Number & " - " & Err.Description
    Resume exitHandler
    End If
    
    End Sub
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    What happens when you try?

    I tried running your code and get error "... problem occurred while Microsoft Access was communicating with the OLE server or ActiveX Control ..."

    I tested this in my db and filter not applied to export. I tried ribbon, right click, setting Filter property.

    This does work:

    Set qdf = CurrentDb.CreateQueryDef("qryTemp", "SELECT * FROM Umpires WHERE " & Me.ctrUmpires.Form.Filter)

    But only when Filter Property is set, not with ribbon or right click filter. And if Filter property is not set it will error.

    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: 26
    Last Post: 04-07-2020, 02:29 AM
  2. Replies: 11
    Last Post: 05-13-2015, 11:10 PM
  3. Replies: 4
    Last Post: 06-04-2014, 01:25 PM
  4. export subforms values to excel
    By darwish in forum Access
    Replies: 2
    Last Post: 04-29-2014, 01:35 AM
  5. Subforms Inside Subforms
    By LordPanzer in forum Access
    Replies: 1
    Last Post: 10-11-2013, 05:19 PM

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