Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question 2: Trying to output datasheet to XLS file with specific name 1

Status
Not open for further replies.

yogi71

Technical User
Apr 5, 2013
13
US
My VB knowledge is minimal, I used to be more proficient at it, but I found it isn't like riding a bicycle...at least not for me.
Once upon a time, I had a DB that did exactly what I am looking to do, but I can't for the life of me figure out how to code it.

I have a button on a form, that when the button is pushed, is SUPPOSED to create an XLS output file based on what is showing in the subform/datasheet, and then pop-up a message box saying its done. So far, the only thing it does is popup the message box, until I moved it after the file creation.

The file created is supposed to be placed at s:\Exports and is supposed to be named <the value in the Name field><date()>.xls

The main form is frmSubmitTime. The sub form/datasheet is frmTimeSheetReview.

Code:
Private Sub modSubmitData()
On Error GoTo modSubmitData_Err

Dim strfile1 As String

    strfile1 = "s:\Exports\" & frmTimeSheetReview.Name & Date() & ".xls"
    DoCmd.OutputTo acOutputForm, "frmTimeSheetReview", "Excel97-Excel2003Workbook(*.xls)", strfile1, False, "", , acExportQualityPrint



    MsgBox "Time submitted.", vbOKOnly, "Time submital"
    
modSubmitData_Exit:
    Exit Sub

modSubmitData_Err:
    MsgBox Error$
    Resume modSubmitData_Exit

End Sub

Please help me solution this.
 
Try

strFile1 = "S:\Exports\" & Me.NAME & ".xls"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, strQuery, strFile1, Yes




Karl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top