473,471 Members | 1,874 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Exporting & opening the Save As Dialog Box

I'd like to provide an Export Function from my forms, where the User
can choose the File name & save location
Although I cannot get the "Save As" dialog box to open properly from
access.
What is the proper code to get Access to open the Windows Save As
dialog box?
Thanks

Apr 30 '07 #1
8 21835
On 30 Apr 2007 05:29:49 -0700, pa****@gmail.com wrote:

Check this out:
http://www.mvps.org/access/api/api0001.htm

-Tom.

>I'd like to provide an Export Function from my forms, where the User
can choose the File name & save location
Although I cannot get the "Save As" dialog box to open properly from
access.
What is the proper code to get Access to open the Windows Save As
dialog box?
Thanks
Apr 30 '07 #2
I guess this is all way above me. I read through the code and remarks
regarding it all, although I dont see the method of actually prompting
for this to happen.

'''This can be done by either using the Common Dialog Control in
Access 97 or by using the APIs defined for this purpose. ???

On Apr 30, 10:03 am, Tom van Stiphout <no.spam.tom7...@cox.netwrote:
On 30 Apr 2007 05:29:49 -0700, paq...@gmail.com wrote:

Check this out:http://www.mvps.org/access/api/api0001.htm

-Tom.
I'd like to provide an Export Function from my forms, where the User
can choose the File name & save location
Although I cannot get the "Save As" dialog box to open properly from
access.
What is the proper code to get Access to open the Windows Save As
dialog box?
Thanks- Hide quoted text -

- Show quoted text -

May 2 '07 #3
When/Where do I actually pass the Data (datasheet) to this code?
I can run it as is, but It saves nothing

On May 2, 10:31 am, paq...@gmail.com wrote:
I guess this is all way above me. I read through the code and remarks
regarding it all, although I dont see the method of actually prompting
for this to happen.

'''This can be done by either using the Common Dialog Control in
Access 97 or by using the APIs defined for this purpose. ???

On Apr 30, 10:03 am, Tom van Stiphout <no.spam.tom7...@cox.netwrote:
On 30 Apr 2007 05:29:49 -0700, paq...@gmail.com wrote:
Check this out:http://www.mvps.org/access/api/api0001.htm
-Tom.
>I'd like to provide an Export Function from my forms, where the User
>can choose the File name & save location
>Although I cannot get the "Save As" dialog box to open properly from
>access.
>What is the proper code to get Access to open the Windows Save As
>dialog box?
>Thanks- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -

May 2 '07 #4
On 2 May 2007 08:23:17 -0700, pa****@gmail.com wrote:

You initially asked "What is the proper code to get Access to open the
Windows Save As dialog box?". I showed you the code. Sorry if it is
complicated; it's what's needed to get this dialog. There are a few
alternatives, but no appealing ones. Long story.

Now you're asking about exporting data. That's done with
DoCmd.TransferText or DoCmd.TransferSpreadsheet or a few other methods
such as OutputTo. Those methods take the destination filename as one
of their arguments. That filename is what you got when running the
Save As dialog, so you can just use it as the argument for the DoCmd
call:

strSaveFileName = ahtCommonFileOpenSave( _
OpenFile:=False, _
Filter:=strFilter, _
Flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_READONLY)
DoCmd.TransferText acExportDelim, , "someQuery", strSaveFileName, True

-Tom.
>When/Where do I actually pass the Data (datasheet) to this code?
I can run it as is, but It saves nothing

On May 2, 10:31 am, paq...@gmail.com wrote:
>I guess this is all way above me. I read through the code and remarks
regarding it all, although I dont see the method of actually prompting
for this to happen.

'''This can be done by either using the Common Dialog Control in
Access 97 or by using the APIs defined for this purpose. ???

On Apr 30, 10:03 am, Tom van Stiphout <no.spam.tom7...@cox.netwrote:
On 30 Apr 2007 05:29:49 -0700, paq...@gmail.com wrote:
Check this out:http://www.mvps.org/access/api/api0001.htm
-Tom.
>I'd like to provide an Export Function from my forms, where the User
can choose the File name & save location
Although I cannot get the "Save As" dialog box to open properly from
access.
What is the proper code to get Access to open the Windows Save As
dialog box?
Thanks- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -
May 3 '07 #5
Cool, I get it now (for the most part).
I just put the code into its own module. (didnt alter it at all). &
Used the transfer spreadsheet commands, which inherintly use said code
from the module.
I still have 3 issues to resolve though;

1. I cannot export as dBase, or CSV files... only XLS works. I added
the strFilters as such;
strFilter = ahtAddFilterItem(strFilter, "dBASE Files (*.dbf)",
"*.DBF")
strFilter = ahtAddFilterItem(strFilter, "Text Files (*.txt)",
"*.TXT")
strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xls)",
"*.XLS")
strFilter = ahtAddFilterItem(strFilter, "CSV Files (*.csv)",
"*.CSV")

I get the following error when trying to save as these other file
types;
Run-time error '3027' Cannot update. Database or object is read-
only.
I tried removing the spreadsheet type from the export code. It still
exports fine for XLS but didnt change the error for the other
filetypes.

2. I cannot get the overwrite prompt to work. I added the flags
included in the Save As Dialog module, but to no avail...it still
always overwrites. I tried adding it as lnflags (previously Dim'd _ As
long) & adding the ahtOverwriteprompt to the transfer cmd itself.

3. Is there a way I can get the export to export from the Current
Form's, current record only?
Do I need to transfer the form data to a temporary table to do
this?
(The transfer spreadsheet cmd only accepts queries & tables
right?

May 3 '07 #6
Ok, I got the Overwrite prompt to work (had previously placed the
Flags into the code improperly)
I still have the other 2 issues to resolve though;
1. I cannot export as dBase, or CSV files... only XLS works.
I added the strFilters as such;
strFilter = ahtAddFilterItem(strFilter, "dBASE Files (*.dbf)",
"*.DBF")
strFilter = ahtAddFilterItem(strFilter, "Text Files (*.txt)",
"*.TXT")
strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xls)",
"*.XLS")
strFilter = ahtAddFilterItem(strFilter, "CSV Files (*.csv)",
"*.CSV")
I get the following error when trying to save as these other file
types;
Run-time error '3027' Cannot update. Database or object is read-
only.
I tried removing the spreadsheet type from the export code. It still
exports fine for XLS but didnt change the error for the other
filetypes.

2.
Is there a way I can get the export to export from the Current
Form's, current record only?
Do I need to transfer the form data to a temporary table to do this?
(The transfer spreadsheet cmd only accepts queries & tables right)?
May 3 '07 #7
Ok, so apparently the OutputTo cmd is the required cmd to export data
in dbf/csv formats.
Now I know.

SO ive answered 2 of my 3 questions.
(kinda feel like someone with multi personalities here, replying to my
own posts)

3rd & final...

This export function (Cmd Button) is on a Form which is based on a
query.
I would like to export only the current record as opposed to all
records viewed with the query.
Can this be done within the Export Code? Here is my current export
code;

Private Sub cmdExport_Header_Click()
Dim strFilter As String

strDefaultDir = "c:\"
strDefaultFileName = "File_Name"

strFilter = ahtAddFilterItem(strFilter, "dBASE Files (*.dbf",
"*.DBF")
strFilter = ahtAddFilterItem(strFilter, "Text Files (*.txt",
"*.TXT")
strFilter = ahtAddFilterItem(strFilter, "Text Files (*.txt",
"*.TXT")
strFilter = ahtAddFilterItem(strFilter, "All Files (*.*", "*.*")
strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xls",
"*.XLS")
strFilter = ahtAddFilterItem(strFilter, "CSV Files (*.csv",
"*.CSV")
strSaveFileName = ahtCommonFileOpenSave(ahtOFN_OVERWRITEPROMPT Or
ahtOFN_READONLY, strDefaultDir, strFilter, , , strDefaultFileName,
"Save Header Info", , False)
Me.Repaint
If strSaveFileName <"" Then

DoCmd.OutputTo acOutputForm, "Form_Name", "Microsoft Excel
(*.xls)", strSaveFileName, True
End If
End Sub

May 3 '07 #8
Instead of trying to export the form's current record, I instead
created a Make Table query, based on the table in which the form gets
it data from.
I then added to the query, the criteria which calls for the current
records PK value.
Criteria: "Forms!Formname.FieldName".
Then in the export code, just export the newly made table with the
single record.
The make table query will always overwrite it's current data so there
is no ongoing maintenance.
voila

DoCmd.Echo False
DoCmd.SetWarnings False
DoCmd.OpenQuery "qrySpec_Record_Export", acViewNormal, acAdd
DoCmd.Echo True
DoCmd.SetWarnings True

....

DoCmd.OutputTo acOutputTable, "SpecRec_Temp", "Microsoft Excel
(*.xls)",
strSaveFileName, True

May 4 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Venkat | last post by:
Hi, I have an file1.exe file stored at some physical location say C:\Test\file1.exe. I created a virtual folder say MyFolder pointing to my physical folder(C:\Test\). I wrote this piece of...
3
by: bbxrider | last post by:
running win2k adv server/ iis5.0 trying to setup on my web page where browsers can download a file, an .xls so been trying to figure out with a download 'link' what invokes the standard ms file...
7
by: joseph.inglis | last post by:
I have a web browser object on a form which I have set to edit mode and use the UCOMIConnectionPointContainer interface to hook in and catch events. All working sweetly. Except there...
1
by: Vijay Neelam | last post by:
Hi all, Dim a As String = Response.ContentType Response.Clear() Response.Buffer = True Response.ContentType = "application/msword" Response.AddHeader("content-disposition", "attachment;...
0
by: Dune | last post by:
Hi there, I have an aspx page that allows users to enter several parameters using drop downs and text boxes. The users then press a button that produces an extract based on the parameters they...
0
by: Bryan Ax | last post by:
Every time I've worked with saving files from the web, I have always used code like the following to force a save dialog where a consumer can choose to open or save the file. string fileName =...
4
by: Satya | last post by:
I am trying to display a PDF file (which I am being passed from a web service as a binary stream) in a browser, but I am being prompted to save the file instead. I don't want the user to be...
0
by: de4ever | last post by:
I have used open/save dialog box inside update panel in asp.net.but it is not working because of the code line Response.WriteFile(path);.Can i use any thing else for opening a file through open/save...
1
by: jekhorton | last post by:
I want to open a save dialog box instead of bringing up the file's data within the browser. I have read in other posts how to do that, but I am having problems with it. The file contents is still...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
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...
0
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...
1
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.