Help Please - Prompt for Location... (1 Viewer)

doran_doran

Registered User.
Local time
Today, 06:20
Joined
Aug 15, 2002
Messages
349
Hi,

I am using following code to export PDF and it's working fine.

1. How do I prompt for location ? (like what drive or directory to save, end user will nagivate this)

2. How do I prompt a Msgbox "No data to print" if there is nothing to print.

Thanks

= = = = Working Code = = = =
Private Sub cmdSaveReportAsPDF_Click()

If ValidateRptData() = True Then
Dim ReportName As String
Dim FileName As String
Dim DateToday As Date

DateToday = Date
ReportName = "rptNP_Main"
FileName = ReportName & " - " & Format(DateToday, "mm-dd-yyyy") & ".pdf"

Call SaveReportAsPDF("rptNP_Main", FileName)
MsgBox "Export completed"
End If

End Sub
 

doran_doran

Registered User.
Local time
Today, 06:20
Joined
Aug 15, 2002
Messages
349
tat did not work...

Micheal suggested mpv website but that did not work. Can someone take my code and make few change please ?
 

ghudson

Registered User.
Local time
Today, 07:20
Joined
Jun 8, 2002
Messages
6,194
If you had searched this forum for "browse" then you would have found many threads with suggestions and samples for what you are seeking. ;)

Check out these APIs for calling the standard windows "File Open" and "Browse Folder" using VBA...

API: BrowseFolder Dialog
http://www.mvps.org/access/api/api0002.htm

API: Call the standard Windows File Open/Save dialog box
http://www.mvps.org/access/api/api0001.htm

You can use the reports OnNoData event to give the user a message that the report does not have any data to print [print preview]. Like this...
Code:
Private Sub Report_NoData(Cancel As Integer)
On Error GoTo Err_Report_NoData
        
    Beep
    MsgBox "Your print request has been canceled." & vbCrLf & vbLf & "Please ensure you have selected the correct criteria before printing.", vbOKOnly + vbCritical, "No Records To Print"
    Cancel = True
        
Exit_Report_NoData:
    Exit Sub
    
Err_Report_NoData:
    MsgBox Err.Number & " - " & Err.Description
    Resume Exit_Report_NoData
    
End Sub
 
Last edited:

Users who are viewing this thread

Top Bottom