Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2012

    Unanswered: Exporting Form to Excel

    Hi. I was wondering if two things were possible.

    a) when exporting a form to Excel, can you filter it based on the current results? I have tried the following but I must be missing something.

    Private Sub Export_Manifest_Click()
    'Declare Variables to hold the Original and Modified Record Sources.
    Dim strOriginalRecordSource As String
    Dim strNewRecordSource As String
    'Retrieve the Original Record Source of the Form
    strOriginalRecordSource = Me.RecordSource
    'Create a New Record Source based on the Primary Key displayed on the Form
    strNewRecordSource = "SELECT * FROM dbo_BM_Product WHERE Product_ID = " & Me![Prod_ID]
    'Apply the Filtered Record Source to the Form
    Me.RecordSource = strNewRecordSource
    'Output the Single, Form Record
    DoCmd.OutputTo acOutputForm, "BM_Maps", acFormatXLS, "C:\Temp\Map_Manifest.xls", False
    'Restore the Original Record Source
    Me.RecordSource = strOriginalRecordSource
    End Sub
    b) Is it possible to export a form and subform together or can you only export one form at a time??

    Thanks in advance

  2. #2
    Join Date
    Apr 2005
    Zagreb - Croatia
    Try to do it vai Query, not form.
    Query in Excel via OutputTo method.

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