By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,465 Members | 1,163 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,465 IT Pros & Developers. It's quick & easy.

Adding current date to a file name automatic

P: 3
Dear sirs i create a macros in access 2010 and i choose " export with formatting."
Inside the "output file" i wrote the below:
Expand|Select|Wrap|Line Numbers
  1. "C:\documents and settings\rabih\desktop\abr\cl-" & format(date(), "yymmdd") & ".pdf"
The above didn't worked so what is wrong with the code
Apr 11 '14 #1
Share this Question
Share on Google+
13 Replies


zmbd
Expert Mod 5K+
P: 5,397
1) Macro or VBA

Macro is NOT equal to VBA. These are two separate programming languages used within Access

2) You tell us what the issue is, what is this doing vs. what it is that the code is doing.

Because when I resolve your string using today's date it returns: C:\documents and settings\rabih\desktop\abr\cl-140411.pdf

3) So it seems that your should, perhaps, trouble shoot your entire code - follow the guidelines given here:[*]> Before Posting (VBA or SQL) Code

4) Once you've followed the basic trouble shooting as given in #3 above, then post your entire code, please format it using the [CODE/] format button in the post-toolbar.
Apr 11 '14 #2

P: 3
Sorry for the missunderstanding i am using access macro only and this code didnt returned your result it simply provide me error #2302
Apr 11 '14 #3

Expert 100+
P: 1,240
Salame,
I had to Google error 2302 to get the description. That's something you should have provided from the beginning. Help us help you.

I found this link informative:
http://support.microsoft.com/kb/226526

The upshot of it is that the most likely error is the path does not exist. Assuming you were logged in as user rabih scurity should not have been the cause of hte problem.

Why don't you step toward a final solution by making a simple change to the macro. First, make a folder at C:\Temp. Just to be sure you have security privileges, copy and paste anything to that folder.

Then change your macro to deposit the file in C:\Temp. Whether the macro works or not you will have learned something. Come back and let us know if it worked or not and we can go from there.

JIm
Apr 11 '14 #4

P: 3
I can copy and open a folder in c: no problem but i tried the code and didnt worked same error i tried also the below

"C:\br-" & format(date(), "ddmmyy") & ".xlsx"
Same error
Apr 11 '14 #5

Expert 100+
P: 1,240
Leave the output format and filename blank. Access will ask for those when you run the macro. Play with different answers, different types and paths. Especially type ... maybe there is some dependency that is not fulfilled. Try html format, that should be free of any dependency.

Jim
Apr 11 '14 #6

zmbd
Expert Mod 5K+
P: 5,397
1) Open the macro in edit view
2) Select/click into one line
3) <ctrl><a> to select ALL of the lines of code
4) <ctrl><c> to copy the code to the clipboard
5) in the post box for this thread, click on the [Code/] button in the toolbar
6) place your coursor between the [code] [/code] tags
7) <ctrl><v> to paste your macro code in between the [code] [/code] tags
8) smile and post.
Apr 13 '14 #7

NeoPa
Expert Mod 15k+
P: 31,768
The macro command you are using does not take code. It needs a string value (without quotes). Not an expression.

This failed :
Expand|Select|Wrap|Line Numbers
  1. "C:\Temp\APB20140414.Xls"
This worked :
Expand|Select|Wrap|Line Numbers
  1. C:\Temp\APB20140414.Xls
Apr 13 '14 #8

zmbd
Expert Mod 5K+
P: 5,397
NeoPa, did OP post the macro script?
I don't see it on my side of the pond.
Apr 14 '14 #9

NeoPa
Expert Mod 15k+
P: 31,768
No Z. Nothing more than the OP itself.

The description of the macro and the parameter they did include showed me that they were expecting the expression to resolve to a string. This won't happen as the macro command expects a resolved string value without quotes (as explained in previous post).
Apr 14 '14 #10

zmbd
Expert Mod 5K+
P: 5,397
Shows my inexperience with the macro side... learned vba and never looked back
(z.... come to the darkside... macros are your friend... OH NO, LOOK OUT MR BILL!)
Apr 15 '14 #11

Expert 100+
P: 1,240
Maybe when I have 28000+ posts I won't say this, but working in Access, I believe I could learn something new every day no matter how long my career lasts.

Jim
Apr 15 '14 #12

zmbd
Expert Mod 5K+
P: 5,397
J - I don't think at even that many posts I'll be anywhere near to scratching the surface. Access is a lot like Chemistry, the more I learn the more I realize that I truely I know, let alone understand, very little of the totality!
I think that's what's so fun about both!
(^_^)
Apr 15 '14 #13

NeoPa
Expert Mod 15k+
P: 31,768
That's where we differ Jim. I can expect to learn something every day in Access. I'm now communicating regularly with other Access MVPs and past MVPs and there's much I still pick up frequently (Maybe not completely new every day but it never gets boring).

@Z.
Like you I know very little about macros and I have a very healthy distrust of them generally and any projects that include them. However, I guessed where the problem might be and knocked one up in an existing database to test out my hypothesis. Obviously, I deleted it again once I'd found out what I needed to know ;-)
Apr 15 '14 #14

Post your reply

Sign in to post your reply or Sign up for a free account.