By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,456 Members | 1,529 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,456 IT Pros & Developers. It's quick & easy.

Save As Type Dialog

P: n/a
Hello,

I'm using Access 97 and I would like to save a query but, give the user
the option of the type (e.g. Txt, Xl, Mdb, dbf) etc.

I see this functionality in the Save/Export, Save as type....where one
can select the file format/type.

How can I call this dialog?

I know and have used the "Transfer*" type functions and also the
"Outputto" functions to save as a specific file type. Thats fine!

I would prefer to allow the user to determine whether they want to save
the data as: Excel, Text, Dbf... etc

Alternatively, is it possible to get a recordset into the "Filename"
parameter in the "Open/Save Dialog" API at
http://www.mvps.org/access/api/api0001.htm
Thank you for any help provided.

Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
os******@eircom.net wrote:
Hello,

I'm using Access 97 and I would like to save a query but, give the user
the option of the type (e.g. Txt, Xl, Mdb, dbf) etc.

I see this functionality in the Save/Export, Save as type....where one
can select the file format/type.

How can I call this dialog?


It's an API (Application Programmer Interface) that, among others, is
documented on

http://www.mvps.org/access/api/api0001.htm

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #2

P: n/a
I'm OK now... I got it working. I misinterpreted how to use the
ahtCommonFileOpenSave.
Thank you and a Merry Christmas and Happy New Year to all.

Nov 13 '05 #3

P: n/a
Back again with more questions and request for assistance....
Using the "File/Open Dialog API" from
http://www.mvps.org/access/api/api0001.htm, I have created the
following function to allow the user to select either - dbf, xls or
csv(txt) - when exporting data (query or table) to a file.

Function Export_File_Choices()
On Error GoTo Export_File_Choices_Err

Dim strFilter As String
Dim varFileName As String

strFilter = ahtAddFilterItem(strFilter, "dBASE Files (*.dbf)", "*.dbf")
strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xls)", "*.xls")
strFilter = ahtAddFilterItem(strFilter, "CSV Files (*.csv)", "*.csv")

varFileName = ahtCommonFileOpenSave( _
OpenFile:=False, _
InitialDir:="F:\", _
Filter:=strFilter, _
FilterIndex:=2, _
DialogTitle:="Save File As...")

Select Case Right(varFileName, 1)
Case Is = "F"
DoCmd.TransferDatabase acExport, "dBase IV", Left(varFileName, 3),
acTable, "tblCarcass", RTrim(Mid(varFileName, 4, 20)), False
Case Is = "S"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97,
"tblCarcass", varFileName, True
Case Is = "V"
DoCmd.TransferText acExportDelim, "Carcass Export Specification",
"tblCarcass", varFileName
End Select

If varFileName = "" Then
MsgBox "No File exported.", vbInformation
Exit Function
End If

Export_File_Choices_Cont:
MsgBox "File exported successfully.", vbInformation
Exit Function

Export_File_Choices_Err:
Select Case Err
'Handle a specific error here
Case 1
MsgBox "Error has occurred"
'Any other error
Case Else
MsgBox Err.Description, vbCritical
End Select

Resume Export_File_Choices_Cont

End Function
What I would appreciate very much is:

1. If someone can improve it for me
2. If someone could suggest how to make the function "Generic" i.e. if
the table name could be passed as a variable from a call
3. If someone could suggest how to incorporate a "DAO Recordset" for
example when typically used with writing to a file using "Print # or
Write #"

Apologies for any word wrap. Thanks for any suggestions and
solutions....

osmethod

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.