Adding current date to a file name automatic

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Salamerabih
    New Member
    • Apr 2014
    • 3

    Adding current date to a file name automatic

    Dear sirs i create a macros in access 2010 and i choose " export with formatting."
    Inside the "output file" i wrote the below:
    Code:
    "C:\documents and settings\rabih\desktop\abr\cl-" & format(date(), "yymmdd") & ".pdf"
    The above didn't worked so what is wrong with the code
    Last edited by zmbd; Apr 11 '14, 07:44 AM.
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    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.
    Last edited by zmbd; Apr 11 '14, 07:58 AM.

    Comment

    • Salamerabih
      New Member
      • Apr 2014
      • 3

      #3
      Sorry for the missunderstandi ng i am using access macro only and this code didnt returned your result it simply provide me error #2302

      Comment

      • jimatqsi
        Moderator Top Contributor
        • Oct 2006
        • 1290

        #4
        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:


        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

        Comment

        • Salamerabih
          New Member
          • Apr 2014
          • 3

          #5
          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

          Comment

          • jimatqsi
            Moderator Top Contributor
            • Oct 2006
            • 1290

            #6
            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
            Last edited by jimatqsi; Apr 11 '14, 12:03 PM. Reason: spelling

            Comment

            • zmbd
              Recognized Expert Moderator Expert
              • Mar 2012
              • 5501

              #7
              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.

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32645

                #8
                The macro command you are using does not take code. It needs a string value (without quotes). Not an expression.

                This failed :
                Code:
                "C:\Temp\APB20140414.Xls"
                This worked :
                Code:
                C:\Temp\APB20140414.Xls

                Comment

                • zmbd
                  Recognized Expert Moderator Expert
                  • Mar 2012
                  • 5501

                  #9
                  NeoPa, did OP post the macro script?
                  I don't see it on my side of the pond.

                  Comment

                  • NeoPa
                    Recognized Expert Moderator MVP
                    • Oct 2006
                    • 32645

                    #10
                    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).

                    Comment

                    • zmbd
                      Recognized Expert Moderator Expert
                      • Mar 2012
                      • 5501

                      #11
                      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!)

                      Comment

                      • jimatqsi
                        Moderator Top Contributor
                        • Oct 2006
                        • 1290

                        #12
                        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

                        Comment

                        • zmbd
                          Recognized Expert Moderator Expert
                          • Mar 2012
                          • 5501

                          #13
                          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!
                          (^_^)

                          Comment

                          • NeoPa
                            Recognized Expert Moderator MVP
                            • Oct 2006
                            • 32645

                            #14
                            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 ;-)

                            Comment

                            Working...