473,387 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Access 2007 hanging on exit, after exporting report to PDF

patjones
931 Expert 512MB
Hi,

It feels strange to be the one doing the asking after so much answering, but this one is driving me crazy.

I have a simple database with a table, a form, and a report based on the table. It's something I made quickly to test out an idea, and so the table only has four or five records of useless data in it.

The idea is for the user to click a command button on the form, which will cause a system folder picker to display. Upon selecting a location and hitting OK, the report in the database gets exported to that location as a PDF named according to the report's caption. The code in the On Click event for the button is as follows:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdExportReport_Click()
  2.  
  3. Dim strFolder As String
  4. Dim fd As FileDialog
  5.  
  6. Set fd = Application.FileDialog(msoFileDialogFolderPicker)
  7.  
  8. If fd.Show = -1 Then
  9.     strFolder = fd.SelectedItems.Item(1)
  10. Else
  11.     Exit Sub
  12. End If
  13.  
  14. DoCmd.OutputTo acOutputReport, "rptEmployeeBirthDates", acFormatPDF, strFolder & "\" & Report_rptEmployeeBirthDates.Caption & ".pdf"
  15.  
  16. Set fd = Nothing
  17.  
  18. End Sub

This works fine, but when I subsequently try to close the database, Access freezes and I have to shut it down using Task Manager. Now, if I open the folder picker and hit "Cancel" (no exporting going on), I have no problem. It's only if Access actually exports the report that I run into trouble.

Any ideas?

Pat
May 1 '10 #1

✓ answered by Jim Doherty

@NeoPa
Silly me! PDF format......... not Access 2000 even sillier the title says Access 2007 haha a senior moment I think

OK If this is Access 2007 (which I hasten to add I am not savvy with yet) then it certainly did not like the command line to output to PDF using the caption property of a report where we are concatenating the folder and caption property as filename destination for the file. To grab this I had to open the report hidden in design grab it to a variable and then do the rest

I used the code for the filepicker posted only the following portion differs

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "rptEmployeeBirthDates", acViewDesign, "", "", acHidden
  2. mycaption = Reports!rptEmployeeBirthDates.Caption
  3. DoCmd.Close , "rptEmployeeBirthDates", acSaveNo
  4. DoCmd.OutputTo acOutputReport, "rptEmployeeBirthDates", acFormatPDF, strFolder & "\" & mycaption & ".pdf", False, "", 0, acExportQualityPrint
Other than this I never had any hangs or misfits

11 4492
patjones
931 Expert 512MB
I should add that when I manually do the export by right-clicking on the report in print preview and selecting the PDF option, I don't have any problem exiting Access. So the title of my thread might be a little misleading as it probably has less to do with exporting something to a PDF and more to do with the system folder picker box. Thanks.

Pat
May 2 '10 #2
Jim Doherty
897 Expert 512MB
@zepphead80
subscribing - I,ll see what I can do on my laptop to replicate your position which version access you using I have 2000 and 2007 only on my machine?
May 2 '10 #3
NeoPa
32,556 Expert Mod 16PB
I would hazard Access 2007 Jim ;)
May 2 '10 #4
robjens
37
I have the same with 2003 on this machine when I close the application. Everything exits fine but the MDI freezes. Run vista on a quad here and never saw that anywhere else ... weird stuff
May 2 '10 #5
NeoPa
32,556 Expert Mod 16PB
As a matter of logic, I would consider re-ordering the code to reflect the basics of what's happening :
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdExportReport_Click()
  2.  
  3.     Dim strFolder As String
  4.     Dim fd As FileDialog
  5.  
  6.     Set fd = Application.FileDialog(msoFileDialogFolderPicker)
  7.  
  8.     If fd.Show Then
  9.         strFolder = fd.SelectedItems.Item(1)
  10.         DoCmd.OutputTo acOutputReport, _
  11.                        "rptEmployeeBirthDates", _
  12.                        acFormatPDF, _
  13.                        strFolder & "\" & Report_rptEmployeeBirthDates.Caption & ".pdf"
  14.     End If
  15.  
  16.     Set fd = Nothing
  17.  
  18. End Sub
Can you let us know if this gives the same problem (I see nothing specific that could be thought of as wrong in your current code by the way)?
May 2 '10 #6
Jim Doherty
897 Expert 512MB
@NeoPa
Silly me! PDF format......... not Access 2000 even sillier the title says Access 2007 haha a senior moment I think

OK If this is Access 2007 (which I hasten to add I am not savvy with yet) then it certainly did not like the command line to output to PDF using the caption property of a report where we are concatenating the folder and caption property as filename destination for the file. To grab this I had to open the report hidden in design grab it to a variable and then do the rest

I used the code for the filepicker posted only the following portion differs

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "rptEmployeeBirthDates", acViewDesign, "", "", acHidden
  2. mycaption = Reports!rptEmployeeBirthDates.Caption
  3. DoCmd.Close , "rptEmployeeBirthDates", acSaveNo
  4. DoCmd.OutputTo acOutputReport, "rptEmployeeBirthDates", acFormatPDF, strFolder & "\" & mycaption & ".pdf", False, "", 0, acExportQualityPrint
Other than this I never had any hangs or misfits
May 2 '10 #7
patjones
931 Expert 512MB
Ohhh, but I think you might be on to something here. I am not opening the report first; I have a feeling that's going to fix it. I'll try it out later when I have time and let you know. Thanks for looking into it!

Pat
May 2 '10 #8
robjens
37
I had a situation with .pdf too and no real solution since there wasn't any pdf output format in Access. We did have distiller (and thus the pdf printer) so I took this approach
  • Set Application.Printer = Application.Printers("Adobe PDF")

The drawback is that it's hard to automate the user response to the dialog from Acrobat and I went through some length to find short usuable code for sending keystrokes to the dialog but never really got it. Must have spent at least 2 days looking. So I had to disable the dialog box and set the output directory for the file manually on some workstations. Which is ok on a smaller scale I guess.

But since there is a vb const now for .pdf, not having worked with it myself, I guess would favour depending how long you wanna spend getting it to work ;)

Also I never got passed that problem where a +1 row counter made during print of the Access form, would after printing to .pdf keep counting so my acc report would say 1 to 50, and then 50 to 100 on the pdf file... Ugh
May 2 '10 #9
patjones
931 Expert 512MB
Jim, that works great. Incorporating NeoPa's suggestion, the code is as follows:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdExportReport_Click()
  2.  
  3. Dim strFolder As String
  4. Dim strCaption As String
  5. Dim fd As FileDialog
  6.  
  7. Set fd = Application.FileDialog(msoFileDialogFolderPicker)
  8.  
  9. If fd.Show Then
  10.  
  11.     strFolder = fd.SelectedItems.Item(1)
  12.  
  13.     DoCmd.OpenReport "rptEmployeeBirthDates", acViewDesign, , , acHidden
  14.     strCaption = Reports!rptEmployeeBirthDates.Caption
  15.     DoCmd.Close acReport, "rptEmployeeBirthDates", acSaveNo
  16.  
  17.     DoCmd.OutputTo acOutputReport, "rptEmployeeBirthDates", acFormatPDF, strFolder & "\" & strCaption & ".pdf"
  18.  
  19. End If
  20.  
  21. Set fd = Nothing
  22.  
  23. End Sub

Thanks!

Pat
May 4 '10 #10
Jim Doherty
897 Expert 512MB
@zepphead80
You,re very welcome Pat :)
May 4 '10 #11
NeoPa
32,556 Expert Mod 16PB
8-) Pat. I'm very pleased to have been a little help at least.
May 4 '10 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Andrew Arace | last post by:
I scoured the groups for some hands on code to perform the menial task of exporting table data from an Access 2000 database to Oracle database (in this case, it was oracle 8i but i'm assuming this...
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
2
by: Gamesetal | last post by:
I need to include a picture / photograph in a Db then from a query export to Excel - picture included - I just can't find a way through this - can anyone please help? TIA JOhn
52
by: Neil | last post by:
We are running an Access 2000 MDB with a SQL 7 back end. Our network guy is upgrading to Windows Server 2003 and wants to upgrade Office and SQL Server at the same time. We're moving to SQL Server...
9
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result...
4
by: myemail.an | last post by:
Hi all, I use Access 2007 and have the following problems: when exporting banal select queries (either to Excel or to a csv file) I find that exporting often doesn't work and creates a file with...
4
by: robtyketto | last post by:
Greetings, I originally used a button on a from created via the button wizard (access 2007) to run my report which was based on a query. Since I wanted to add some validation I removed the...
5
by: Tony | last post by:
I am continuing to develop an Access 2007 application which was originally converted from Access 2003. In Access 2003 I was able to disable the Access Close button in the top righthand corner of...
1
by: Mientje | last post by:
I've made an Access 2007 database to store information about the lessonplans I have to make every schoolyear. I want to export the data form the table "Lesvoorbereiding" (Lessonplans in English) to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.