473,563 Members | 2,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access 2007 hanging on exit, after exporting report to PDF

patjones
931 Recognized Expert Contributor
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
11 4502
patjones
931 Recognized Expert Contributor
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 Recognized Expert Contributor
@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,564 Recognized Expert Moderator MVP
I would hazard Access 2007 Jim ;)
May 2 '10 #4
robjens
37 New Member
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,564 Recognized Expert Moderator MVP
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 Recognized Expert Contributor
@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 Recognized Expert Contributor
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 New Member
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.Pri nter = Application.Pri nters("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 Recognized Expert Contributor
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

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

Similar topics

1
9184
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 will work for 9i and even 10g ) No one had what I needed, so I wrote it myself. I Rule. This code isn't going for efficiency, and isn't trying...
7
8834
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 want my users to be able to select a report, click on a command button on a form, which will then automatically create the report as a pdf file and...
11
6564
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 where the job is running, the job runs sucessfully, PDF files got generated, everything is good. If I scheduled the job to run at the time that I am...
2
1496
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
9935
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 2005, and, since he already has licenses for Office Pro 2002, he wants to upgrade to that. I've been saying that we need to upgrade to Access...
9
3929
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 - I have read every post out there and spent hours trying to figure out the problem with no success whatsoever - I have constrained the problem to...
4
2380
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 the WHOLE dataset, i.e. including those rows which the criteria of the query excluded. For example: let's say I have a database with sales by...
4
6051
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 button and added my own code (as below):- However the open report is just a preview and the user cant exit the preview screen without directly...
5
5872
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 the screen. I have been unable to find any way to disable this button in Access 2007 and subsequently I have been forced to find ways to detect and...
1
3501
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 Word using a readymade template (NLD-LV1.dotx). All works well except for the multivalued fields 'Lesuur' (Lessonhour) and 'Werkvormen' (Used...
0
7580
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7882
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8103
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7634
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7945
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6244
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5481
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
2079
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.