473,320 Members | 1,857 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,320 software developers and data experts.

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 21811
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: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.