My Assistant
![]() ![]() |
|
|
Feb 27 2012, 04:43 PM
Post
#1
|
|
|
UtterAccess Ruler Posts: 1,888 From: US Army / Iraq |
Greetings all:
Not quite sure why this is not working....I get it to work fine on queries that do not require a parameter or tables. I have a query that uses a filter by form to get the result. I need to export the result of the query but cannot get it to export. The parameter is correct... My code: CODE Set objBook = Workbooks.Add(Template:=CurrentProject.Path & "\WORKBOOK_TEMPLATES\ALPHA_ROSTER.xltx") Set objApp = objBook.Parent Set objSheet = objBook.Worksheets("ALPHA ROSTER") Set rst = db.OpenRecordset("QRY_EXPORT_ALPHA_ROSTER", dbOpenSnapshot) With objSheet .Select .Range("ALPHA ROSTER").Clear .Range("A2:AO5000").CopyFromRecordset rst End With rst.Close Has anyone else ever had this issue. Please HELP!!!! Thanks (IMG:style_emoticons/default/smile.gif) Dan This post has been edited by strive4peace: Apr 9 2012, 12:22 AM
Reason for edit: fixed indents
|
|
|
|
Apr 9 2012, 12:20 AM
Post
#2
|
|
|
UtterAccess VIP Posts: 20,187 From: Colorado |
Hi Dan,
I don't think this is a good statement: .Range("ALPHA ROSTER").Clear perhaps the code is not getting to the CopyFromRecordset line ... put an error handler in your code -- modify the "shell" error handling code I posted. Error Handling http://www.AccessMVP.com/strive4peace/Code.htm also, please post your entire procedure, thanks (IMG:style_emoticons/default/smile.gif) |
|
|
|
Apr 9 2012, 01:16 AM
Post
#3
|
|
|
UtterAccess Ruler Posts: 1,090 |
there should be an error here:
.Range("ALPHA ROSTER").Clear range Name does not allow space character inside the name. to delete the entire content of objSheet: objSheet.Cells.Delete |
|
|
|
Apr 9 2012, 04:52 AM
Post
#4
|
|
|
UtterAccess Guru Posts: 594 |
The named range would be invalid. If solving that on its own doesn't fix it then let us know what line it craps out at.
JS |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 21st May 2013 - 11:47 PM |