Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically Naming a report based on Field Name at save prompt

Status
Not open for further replies.

Pistol

MIS
Jan 29, 2001
59
0
0
US
I need help naming a report.
Currently I am giving the option to run a report based on the current record. The report is based on a query that will select the current record.

When the users save the report I would like it to automatically name the report based on values in the current record (i.e. DateRMA#NameFirstNameLast.rtf instead of "RPT_RMA_CURRENT.rtf")

Any Suggestions?
 
create a variable say strReportName, then...

Code:
 strReportName = dateRMA

something to that effect. I used something similar on a report that I save...

Code:
Dim FileName As String
Dim FilePath As String
Dim FileDate As String
    FileName = ""
    FilePath = ""
    FileDate = ""
    
FileDate = InputBox("Enter the date/description of the QCd files: (Format Date as yyyymmdd)", "Description") '= vbCancel Then
If FileDate = "" Then
MsgBox "You didn't specify the date of the file!", vbOKOnly
Exit Sub
Else
'Set Filters
    CommonDialog1.Filter = "Excel Spreadsheets (*.xls) |*.xls"
    CommonDialog1.FilterIndex = 1
    
'Display the Save File Dialog
    CommonDialog1.FileName = "C:\Documents and Settings\" & Environ("username") & "\Desktop\UnmatchedTrx_" & FileDate & ".xls"

There may be cleaner ways to do it, but I'm quite new to VBA and this works for my purposes.

The key part to this for me is where I name the file (right at the end of my code excerpt), and use the info that the user entered into the input box (FileDate). You could alternatively use data from a table or a text box on a form

HTH
-Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top