Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Feb 2002
    Location
    Riverside, California, USA
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Run-time error 7871 (Access 2002)

    I've just encountered an error I can't seem to find info on. I have created a form with a text box called "txtFileName". I've written a SQL statement depending on which fields were selected for output then using the DoCmd.TransferSpreadsheet as follows:

    strLocation = "Cocuments and Settings" & CurrentUser & "Desktop"

    If IsNull(Me.txtFileName) Then
    strLocation = strLocation & Right(Year(Date), 2) & Format(Month(Date), "00") & Format(Day(Date), "00") & "AllUnit3.xls"
    Else
    strLocation = strLocation & Me.txtFileName & ".xls"
    End If

    strSQL = "Whatever the person selected"

    DoCmd.TransferSpreadsheet acExport, , strSQL, strLocation

    Please help! Thanks!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Run-time error 7871 (Access 2002)

    TransferSpreadsheet can only export tables and stored queries; an SQL string is not a valid argument. So you get an error stating that the table name is not correct.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •