Default Database Folder

S

Sudhakara.T.P.

Hi,
I have an application wherein it has lot of reports and i have enabled the
option to export the same onto Word/Excel (the default button that access
provides to do so).

I am accessing this application through a network drive. So when I export, I
want these exported word/excel files to sit in that network drive. This
problem will be solved if i am able to prompt the save file as dialog box,
which I am not able to.

Could anyone please let me know your valuable thoughts on the following
things:
1) Prompt Save File as dialog box when exporting report.
2) change the default database folder to the network drive through VBA code
(the one that we can change through Tools-->General Tab) menu items.

Regards,
Sudhakara.T.P.
 
J

John Spencer

I made a custom button and used the following code. It prompts for the
location and file name.

Public Function funOutputReportToRTF()
'Save the currently selected report to RTF Output
'Called from a button bar or menu item.
'Keywords: Export Report to Word

Dim strObjName As String
Dim intState As Integer
Dim intCurrObjType As Integer
On Error GoTo ERROR_Trap

intCurrObjType = Application.CurrentObjectType 'Get TYPE OF last Report,
'Form, Table, Module, Query, or Macro with cursor

strObjName = Application.CurrentObjectName 'Get object's name

intState = SysCmd(acSysCmdGetObjectState, intCurrObjType, strObjName)

If intCurrObjType = acReport Then
If intState = acObjStateOpen Then 'Report is open (naturally)

'Leaving 4th argument blank causes Access to ask for an output file
name
DoCmd.OutputTo acOutputReport, strObjName, acFormatRTF, , False
End If

Else
MsgBox "Please display a report to output to a word document.", ,
"Preview a Report"
End If

Exit_Trap:
Exit Function

ERROR_Trap:

If Err.Number = 2501 Then
'Cancel pressed
Else
MsgBox Err.Number & ": " & Err.Description
End If

Resume Exit_Trap

End Function

--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top