vba Run-time error '3190"   Too many fields defined.

ca1358 used Ask the Experts™
I have a table that has 16 fields.  I am trying to export the table out.

I get the Run-time error '3190"   Too many fields defined.

Private Sub SendReports()
'Append End of Day Tables to EXCEL End of Day Tables----- 09/15/2010

DoCmd.TransferSpreadsheet acExport, , "EOD_tbl_PairOut_Sophia", "\\XXXXXXX\XXXXX\BuyerEndofDay\EndOfDay.xls", True, "PairOut_XXXXX"
End Sub

Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2009

I think the problem may be with the Range argument (the last one in your line of code).  This argument is only used when importing from Excel.  Try leaving it out and see what happens.  Also, I recommend using named arguments -- it makes the code much more readable.  Here is a sample:
strPath = Application.CurrentProject.Path
strWorkbook= strPath & "Customers.xls"

DoCmd.TransferSpreadsheet transfertype:=acExport, _
   spreadsheettype:=acSpreadsheetTypeExcel8, _
   tablename:="qryCustomers", _
   FileName:=strWorkbook, _

DoCmd.TransferSpreadsheet transfertype:=acImport, _
   spreadsheettype:=acSpreadsheetTypeExcel9, _
   tablename:=strTable, _
   FileName:=strWorkbook, _ 
   hasfieldnames:=True, _

Open in new window

Top Expert 2009

If you need the data from Access to be put into a certain range, you may need to use the CopyFromRecordset method of an Excel range, as in the code below:
Dim appExcel As New Excel.Application
   Dim cnn As ADODB.Connection
   Dim wkb As Excel.Workbook
   Dim sht As Excel.Worksheet
   Dim strWorkbook As String
   Dim strRange As String
   Dim lngLastRow As Long
   Dim rst As ADODB.Recordset
   Dim rng As Excel.Range
   Dim strWorkbookName As String
   Dim strDefault As String
   DoCmd.SetWarnings False
   strPrompt = "Enter workbook name (no extension)"
   strTitle = "Workbook name"
   strDefault = "New Access Data"
   strWorkbookName = InputBox(strPrompt, strTitle, strDefault)
   'Run make-table queries
   DoCmd.OpenQuery "qmakCAContacts"
   Set cnn = CurrentProject.Connection
   Set rst = New ADODB.Recordset
   'Create a recordset based on a select query.
   rst.Open Source:="qryContacts", _
      ActiveConnection:=cnn.ConnectionString, _
   'Export first query
   Set wkb = appExcel.Workbooks.Add
   appExcel.Visible = True
   strWorkbook = Application.CurrentProject.Path & "\" & strWorkbookName
   wkb.SaveAs FileName:=strWorkbook
   Set sht = wkb.Sheets(1)
   strRange = "A1"
   Set rng = sht.Range(strRange)
   rng.CopyFromRecordset rst

Open in new window

Top Expert 2016

try doing a compact and repair
office button >manage > compact and repair

then run the codes

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12 , "EOD_tbl_PairOut_Sophia", "\\XXXXXXX\XXXXX\BuyerEndofDay\EndOfDay.xls", True, "PairOut_XXXXX"
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Top Expert 2012

You have specified a Range (PairOut_XXXXX) which should be blank when exporting.
Top Expert 2016
try this one, see if you still get the error

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12 , "EOD_tbl_PairOut_Sophia", "\\XXXXXXX\XXXXX\BuyerEndofDay\EndOfDay.xls", True, "NameOFSheet"


Thank you.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial