[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 943
  • Last Modified:

VBA Code in Access

DoCmd.OutputTo acReport, "Rpt_employee_Main", "RichTextFormat(*.rtf)", "D:\abc\Report_Employees\" & Format$(Date, "mmddyy") & "_employee_Main.rtf", False, "", 0

The above syntax is taken from MS Access Module, The only thing I can understand in this code is its outputing the report to a given path BUT what does the code mean by "& Format$(Date, "mmddyy") & "_employee_Main.rtf", False, "", 0"
 Please advice
0
Syd2008
Asked:
Syd2008
  • 3
  • 2
  • 2
  • +3
5 Solutions
 
mbizupCommented:
Syd2008,

It is bulding a filename in the format:

D:\abc\Report_Employees\020508_employee_Main.rtf

Where 020508 is a formatted date.
0
 
ldunscombeCommented:
It is going to append the current date to the start of the output file name in a

"010208" format
Leigh
0
 
mbizupCommented:
In other words,
Date() is today's Date.

Format$(Date, "mmddyy")  formats  today's date in a mmddyy format. (020508)
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Rey Obrero (Capricorn1)Commented:
this

Format$(Date, "mmddyy")

is added to the filename   _employee_Main.rtf

to be           020508_employee_Main.rtf

False - not to open the application

look for OutputTo Method in the vba help for more detailed info
0
 
almilyoCommented:
"D:\abc\Report_Employees\" & Format$(Date, "mmddyy") & "_employee_Main.rtf" is all one argument being passed to the OutputTo method of DoCMD. It contatenates constant strings, with the date ( which obviously changes each day) with the intention of producing a new filename for the report each day.

 So on the 6th of February 2008 , this section of code means the report will be output to

d:\abc\Report_Employees\020608_employee_Main.rtf
0
 
ldunscombeCommented:
How quick and how many responses would you like. LOL

0
 
Syd2008Author Commented:
what about <<False, " ", 0" >> ?
Is this report checking any IF statement ?
any idea how to use this OutputTo method of DoCMD in SQL ?
0
 
fsetoCommented:
The "&" is concating the strings in VB.  So it's prefixing the date in front of the filename.  The rest of the doCmd syntax can be found here:
http://www.blueclaw-db.com/docmd_outputto_example.htm
0
 
Rey Obrero (Capricorn1)Commented:
from help

expression.OutputTo(ObjectType, ObjectName, OutputFormat, OutputFile, AutoStart, TemplateFile, Encoding)


AutoStart   Optional Variant. Use True (1) to start the appropriate Microsoft Windowsbased application immediately, with the file specified by the OutputFile    argument loaded. Use False (0) if you don't want to start the application. This argument is ignored for Microsoft Internet Information Server (.htx, .idc) files and Microsoft ActiveX Server (*.asp) files. If you leave this argument blank, the default (False) is assumed.

TemplateFile   Optional Variant. A string expression that's the full name, including the path, of the file you want to use as a template for an HTML (HTML: The standard markup language used for documents on the World Wide Web. HTML uses tags to indicate how Web browsers should display page elements such as text and graphics and how to respond to user actions.), HTX (IDC/HTX files: Microsoft Internet Information Server uses an IDC file and an HTX file to retrieve data from an ODBC data source and format it as an HTML document.), or ASP (Active Server Page (ASP): A file that contains embedded server-side scripting that is executed on a server and sent to and displayed in a client Web browser as a standard HTML file.) file.

Encoding   Optional Variant.

0
 
ldunscombeCommented:
<any idea how to use this OutputTo method of DoCMD in SQL ?>

The OutputTo is a method of the DoCmd object,  SQL is the basis of the object that you want to output, So if you are saying can you output the results of an SQL statement then the answer is yes.

Just create a query with whatever SQL you want and Output the query object instead of the report object.

DoCmd.OutputTo acOutputQuery, "Your query name",....

Leigh

0
 
Syd2008Author Commented:
Thank you everyone
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now