DoCmd.TransferSpreadsheet help

  • Thread starter Thread starter GD
  • Start date Start date
G

GD

trying to export a query ("PBDM DATE RANGE") to Excel. Is my code wrong or
does it need to go further?

Private Sub cmdDCFM_PBDM_Click()
DoCmd.TransferSpreadsheet acExport, 9, "PBDM DATE RANGE", "C:\My
Documents\Trial.xls", True

End Sub

Thanks for your time!
 
What happens when you try running the code? Do you get an error? If so,
what's the erro? If you don't get an error, what does happen?
 
Are you sure that the code is actually linked to the button (code sometimes
gets unlinked).

Look at the Property window. Does it have [Event Procedure] as the value for
the Click property? If you click on the ellipsis (...) to the right of the
property, are you taken into the VB Editor in the midst of that code?
 
Yes, that seems to be OK. Is 9 the right value for an Excel 2003 worksheet?
--
GD


Douglas J. Steele said:
Are you sure that the code is actually linked to the button (code sometimes
gets unlinked).

Look at the Property window. Does it have [Event Procedure] as the value for
the Click property? If you click on the ellipsis (...) to the right of the
property, are you taken into the VB Editor in the midst of that code?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)
 
There isn't a type 9. Try putting acSpreadsheetTypeExcel9 or 8 instead.

You might want to look into some error trapping as an exception should have
been raised. Or maybe you have Set Warning turned off somewhere?
 
As Jerry stated, you should use the named constant acSpreadsheetTypeExcel9
(or acSpreadsheetTypeExcel8)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


GD said:
Yes, that seems to be OK. Is 9 the right value for an Excel 2003
worksheet?
--
GD


Douglas J. Steele said:
Are you sure that the code is actually linked to the button (code
sometimes
gets unlinked).

Look at the Property window. Does it have [Event Procedure] as the value
for
the Click property? If you click on the ellipsis (...) to the right of
the
property, are you taken into the VB Editor in the midst of that code?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


GD said:
Nothing happens when I click the command button.

--
GD


:

What is happening that makes you think that there is a problem?
--
Jerry Whittle - MS Access MVP 2007 - 2009
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder

:

trying to export a query ("PBDM DATE RANGE") to Excel. Is my code
wrong or
does it need to go further?

Private Sub cmdDCFM_PBDM_Click()
DoCmd.TransferSpreadsheet acExport, 9, "PBDM DATE RANGE", "C:\My
Documents\Trial.xls", True

End Sub

Thanks for your time!
 
put a breakpoint on the code and step through it with F8.

how did you connect the code to the button.

might be worth creating a new button, right clicking on it, selecting properties and on_click select 'build event'

-------------------------------------------------------
For your FREE Access beginners ebook

http://www.access-databases.com/ebook

-------------------------------------------------------
 
Back
Top