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: - Private Sub cmdExportReport_Click()
-
-
Dim strFolder As String
-
Dim fd As FileDialog
-
-
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
-
-
If fd.Show = -1 Then
-
strFolder = fd.SelectedItems.Item(1)
-
Else
-
Exit Sub
-
End If
-
-
DoCmd.OutputTo acOutputReport, "rptEmployeeBirthDates", acFormatPDF, strFolder & "\" & Report_rptEmployeeBirthDates.Caption & ".pdf"
-
-
Set fd = Nothing
-
-
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
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
@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?
NeoPa 32,564
Recognized Expert Moderator MVP
I would hazard Access 2007 Jim ;)
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
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 : - Private Sub cmdExportReport_Click()
-
-
Dim strFolder As String
-
Dim fd As FileDialog
-
-
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
-
-
If fd.Show Then
-
strFolder = fd.SelectedItems.Item(1)
-
DoCmd.OutputTo acOutputReport, _
-
"rptEmployeeBirthDates", _
-
acFormatPDF, _
-
strFolder & "\" & Report_rptEmployeeBirthDates.Caption & ".pdf"
-
End If
-
-
Set fd = Nothing
-
-
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)?
@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 - DoCmd.OpenReport "rptEmployeeBirthDates", acViewDesign, "", "", acHidden
-
mycaption = Reports!rptEmployeeBirthDates.Caption
-
DoCmd.Close , "rptEmployeeBirthDates", acSaveNo
-
DoCmd.OutputTo acOutputReport, "rptEmployeeBirthDates", acFormatPDF, strFolder & "\" & mycaption & ".pdf", False, "", 0, acExportQualityPrint
Other than this I never had any hangs or misfits
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
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
patjones 931
Recognized Expert Contributor
Jim, that works great. Incorporating NeoPa's suggestion, the code is as follows: -
Private Sub cmdExportReport_Click()
-
-
Dim strFolder As String
-
Dim strCaption As String
-
Dim fd As FileDialog
-
-
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
-
-
If fd.Show Then
-
-
strFolder = fd.SelectedItems.Item(1)
-
-
DoCmd.OpenReport "rptEmployeeBirthDates", acViewDesign, , , acHidden
-
strCaption = Reports!rptEmployeeBirthDates.Caption
-
DoCmd.Close acReport, "rptEmployeeBirthDates", acSaveNo
-
-
DoCmd.OutputTo acOutputReport, "rptEmployeeBirthDates", acFormatPDF, strFolder & "\" & strCaption & ".pdf"
-
-
End If
-
-
Set fd = Nothing
-
-
End Sub
Thanks!
Pat
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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...
|
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
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
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...
| |
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. ...
|
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...
|
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...
|
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...
|
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...
|
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...
| |
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
|
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...
| | |