×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Hi, I need to put the date in the

Hi, I need to put the date in the

Hi, I need to put the date in the

(OP)
Hi,
I need to put the date in the filename of an access report. I have tried this code as below. The report opens as a PDF OK, but no date.
Got some error here. Any bright suggestions would be appreciated.

CODE

Private Sub Master_Report_Click()
Dim FilePath As String
Dim FileName As String
FilePath = "C:\Users\K\Desktop\Master Report PDF"
FileName = FilePath & Format(Date, "MM-DD-YYYY") & " Master Report"
DoCmd.OutputTo acOutputReport, "Master Report", acFormatPDF, strFullPath, True
End Sub 
Thank you..

RE: Hi, I need to put the date in the

Does your code compile?
You are using strFullPath in your DoCmd line but it has no source/value from what we can tell.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016

RE: Hi, I need to put the date in the

(OP)
Hi Duane,
Thanks for your reply.
Yes the DB does compile. It shows no errors.

RE: Hi, I need to put the date in the

Do you have Option Explicit at the top of all of your modules?

Do you understand you are setting the value of FileName but using strFullPath?

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016

RE: Hi, I need to put the date in the

(OP)
Hi Duane,
Just had to check the option explicit, Had missed out on a couple of forms.
When you compile the Db now shows "Variable not defined on the strFullPath"
But just not sure where to go from here.
What is the better way to write this vba?

Thanks
KP

RE: Hi, I need to put the date in the

DoCmd.OutputTo acOutputReport, "Master Report", acFormatPDF, FilePath , True

RE: Hi, I need to put the date in the

(OP)
Hi Guys,
Thanks for the info.
I have now got it working quite well. have changed thee vba to read as below,

CODE

Private Sub Master_Report_Click()
Dim FilePath As String
FilePath = "C:\PDFTemp\Master Report,     -" & Format(Date, "dd-mm-yyyy") & ".pdf"
DoCmd.OutputTo acOutputReport, "Master Report", acFormatPDF, FilePath, True
End Sub 
The question is if it works is the vba right?.... The space between "Master report" & Date function is for the user to insert his Branch ID
Many thanks,

KP

RE: Hi, I need to put the date in the

Are you expecting your code to stop and wait for the user to enter something?
Isn't the user's branch ID stored in a table that you can retrieve?

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016

RE: Hi, I need to put the date in the

(OP)
Hi Duane,
This code is on a command button. When run, the report opens in PDF and when is is saved as a PDF with the ability for the user to input his Branch ID, however,
Yes, there is a table with the Branch ID plus BranchName etc, but I am just not sure how to add this to the vba.
This table is linked to a table which holds the users logonID and username.

Thanks,
KP

RE: Hi, I need to put the date in the

Do you have any code in your application that can identify the current user? Maybe a function that returns the network login of the current user? Are the user logins stored in your "table with the Branch ID plus BranchName etc"? Is there any other automated ways to get the value you want from the table? Can you add a dropdown on your form to select the Branch ID?

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016

RE: Hi, I need to put the date in the

(OP)
Hi Duane,
To answer your questions,
Within the relationships the Branch table is linked to the User table (one to many) so when a new user is assigned to any branch he has a specific ID linked to that Branch.
So it would be quite easy to put a dropdown on the form to select the BranchID.
So with a query its possible to see the relationship between the user and the assigned Branch.
Hope this makes sense!

RE: Hi, I need to put the date in the

Ok, add the dropdown and set its bound column to the value you want to use in the file name.

CODE --> vba

Private Sub Master_Report_Click()
    Dim FilePath As String
    FilePath = "C:\PDFTemp\Master Report " & Me.[YourComboBoxNameHere] & "-" & Format(Date, "dd-mm-yyyy") & ".pdf"
    DoCmd.OutputTo acOutputReport, "Master Report", acFormatPDF, FilePath, True
End Sub 

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close