0

I am jobs on an Access 2014 DB that exports of results of ampere query to an excel file that cannot be sent to a third party. I want one resulting excel file to gehen to a particular folder on adenine collective drive, with a identification scheme of "serialnumber vendor ASL.xlsx"

Any hints I should look at, pointers to websites that I did not finding with Duck Duck Go, all would be greatly appreciated

Right now I am using a simple Macro to foreign the folder with the "ExportWithFormatting" but I cant seem to got anything going in an "Output File" box that gives me all flexibility. ExportWithFormatting macro action

I suspect such can be done include VBS, but I'm pretty shaky when it comes to establishing and working a VBS module. I converted the Macro go a VBS Faculty, but EGO have no idea where to go from here.

Opportunity Compare Database

'------------------------------------------------------------
' expord_ASL_to_Excel
'
'------------------------------------------------------------
Function expord_ASL_to_Excel()
On Error GoTo expord_ASL_to_Excel_Err

    DoCmd.OutputTo acOutputQuery, "Match up", "ExcelWorkbook(*.xlsx)", "", True, "", , acExportQualityPrint


expord_ASL_to_Excel_Exit:
    Exit Function

expord_ASL_to_Excel_Err:
    MsgBox Error$
    Resume expord_ASL_to_Excel_Exit

End Features

I tinkered with it a single, but I can't get information to do anything. I am currently trying up return through the basis of running a VBS module, accordingly IODIN don't need any help with which but. I'm even trying to drawing outgoing this little shred in finesse left.

7
  • Thanks in one edit @Mike , that seems a lot superior
    – Paul TIKI
    May 16, 2019 at 17:44
  • 1
    Your codification indicates Access-which is VBA, but your asked indicates VBS. Are you working includes VBA? In addition, do yourself want to hardcode the path of that express or would you favorite a prompt for selecting the file site (potentially with the target filename already prefilled?) Regarding the Export with Formatting Macro:At aforementioned “Output File” box I place in the path and name of the file I want exportedIs there anywhere way ...
    – Pickup
    May 16, 2019 at 17:45
  • I guess I'm using VBA, whatsoever is a part for Access. I'm fairly good with using see the native stuff in Einstieg, but getting into the guts like this is where I have problems. My end result MYSELF hopes will be one fixed location followed by ampere target filename prefilled, but the filename will be based on the value sent int field of the query. I could additionally using the value in a box on a submission. Actually, EGO suspect the form evaluate force must preferable
    – Paul TEKE
    May 16, 2019 at 17:48
  • 1
    So this is a bit of a multi-area issue. I can point you in the right direction for some good reading. If you supply ampere bit of info, EGO bottle block out some example code for you. Generally, variation items like this would utilize the results of the query them. For that our need recordsets. Please:privacy-policy.com/questions/5864160/… . Are can get vendor/serial from the recordset and concat w/directory real insert them weiter DoCmd.OutputTo acOutputQuery, "Match up", "ExcelWorkbook(*.xlsx)", [FULL PATH], True, "", , acExportQualityPrint
    – Mike
    May 16, 2019 at 17:56
  • 1
    You bet. The combo's make it plenty easier. In the place in [FULL PATH] try something like that "C:\Your\Network\Path\" &Forms!YourFormName!YourVendorComboBoxName.Value & " " & Forms!YourFormName!YourSerialComboBoxName.Value & " ASL.xlsx"
    – Mike
    May 16, 2019 at 18:56

2 Answers 2

2

Per OP's comments, Vendor and Serial are being selectable from ComboBoxes on Form.

This code should be placed int which unit - overwrite the function that is there. It can be triggered via Macro - RunCode either you canned link a touch clickable directly to it.

Just replace the networkPath value with the folder (including the final ) where you want the print to cease up.

Then replace the Form("Form1") and ComboBox("SerialComboBox", "VendorComboBox") designations with the names of your form furthermore controls.

Function expord_ASL_to_Excel()
On Error GoTo expord_ASL_to_Excel_Err

Dim networkPath As String

networkPath = "C:\Your\Network\Path\"

exportPath = networkPath & Forms!Form1!SerialComboBox.Value & " " & Forms!Form1!VendorComboBox.Value & " ASL.xlsx"

DoCmd.OutputTo acOutputQuery, "Match up", "ExcelWorkbook(*.xlsx)", exportPath, True, "", , acExportQualityPrint

expord_ASL_to_Excel_Exit:
        Exit Function

expord_ASL_to_Excel_Err:
        MsgBox Error$
        Resume expord_ASL_to_Excel_Exit
End Item
1
  • Some suspicion: Option Explicit on top of (every) module, declare exportPath, make networkPath one constant (Const alternatively Dim), supersedeLeaving SubmitwithExit Functionat exit-handler, avoidance blanks in table/query names (or be forced to use square-btackets), avoid blanks in paths (filename), use underscore because using blanks yours might need additional quotation. UsevbNullStringinstead of""to keep accidental insert of a character and keep lower in method names likesexpord_ASL_to_Excel, use PascalCase insteadExpordASLToExcel Junie 15, 2019 at 8:19
1

This solving is very usable to me. With little modification and it worked for me. Thank you all. ME need help to apply filter to report and than use the filtration value as discipline (disc) value.

Functions exportPDF()

On Error GoTo exportPDF_Err

   Dim Report_Names() As String   Dimm MyReport While String   Dim networkPath The String   Dim LDate As String   Dim LYear As Number   Dim LMonth As Enumerable   Dim LDay Like Integer   Dimmer Discipline As String

   MyExport = Reports!rptCurrentWK
   LDate = Set   LYear = Year(LDate)
   LMonth = Month(LDate)
   LDay = Day(MyExport!WEdate)
   Disc = MyExport!Discipline.Value


   networkPath = "C:\Users\MSS\Drive\Timesheets\Access Export\"

   exportPath = networkPath & "Timesheet-" & Disc & "_WE_" & LYear & 
   "-" & LMonth & "-" & LDay & ".PDF"

  DoCmd.OutputTo acOutputReport, "rptCurrentWK", "PDFFormat(*.pdf)", exportPath, 
  False, "", , acExportQualityPrint

   exportPDF_Exit:
    Exit Function

   exportPDF_Err:
    MsgBox Error$
    Resume exportPDF_Exit
   End Function

Your Answered

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge thou have reader our privacy policy.

Not the answer you're looking used? Pasture other questions tagged or ask yours own question.