Import

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • u2cannv
    New Member
    • Oct 2007
    • 5

    Import

    hi,
    I'm trying to use a macro to import a file that contains a certain filename. the catch is the file name will always be the current date. ex. johndoe101707.t xt. i'm new to access so, you may have to simplify the code for me.
    Thanks
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Originally posted by u2cannv
    hi,
    I'm trying to use a macro to import a file that contains a certain filename. the catch is the file name will always be the current date. ex. johndoe101707.t xt. i'm new to access so, you may have to simplify the code for me.
    Thanks
    Code:
    "johndoe" & Right("0" & Month(Date()), 2) & Right("0" & Day(Date()), 2) & Right(Year(Date()), 2) & ".txt"

    Comment

    • u2cannv
      New Member
      • Oct 2007
      • 5

      #3
      Originally posted by Rabbit
      Code:
      "johndoe" & Right("0" & Month(Date()), 2) & Right("0" & Day(Date()), 2) & Right(Year(Date()), 2) & ".txt"

      Thank you, I just tried running the code and it said that i cannot import a file that doesnt contain the following extensions: .txt, .csv, and etc.. i'm not sure if it has something to do with the quotation marks surrounding the txt or what. Thanks for the help so far

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        It's an expression so you have to put = in front of it first.

        Comment

        • u2cannv
          New Member
          • Oct 2007
          • 5

          #5
          ok so far this is my code, if i'm correct i'm inputting this into the macro and the action to be performed is transfer text, correct? after that i impute the code on the line that says filename. File name is where i in put the following:
          \\C\desktop\="j ohndoe" & Right("0" & Month(Date()), 2) & Right("0" & Day(Date()), 2) & Right(Year(Date ()), 2) & ".txt"

          after i insert the equal sign it says that the file must end in .txt or should i write the code in vb and if so, how? here's my code in VB

          [Code=vb]Public Sub import()
          Dim Apel As Date
          Dim APELLES As String
          Dim result As String

          Docmd.TransferT ext = "johndoe" & Right("0" & Month(Date), 2) & Right("0" & Day(Date), 2) & Right(Year(Date ), 2) & ".txt"

          End Sub
          [/Code]
          i get all sorts of errors ranging from object doesnt support this method to variable functions.

          nothing happens here either.
          Thanks a lot.

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            In the filename field, you put:
            Code:
            ="C:\desktop\johndoe" & Right("0" & Month(Date()), 2) & Right("0" & Day(Date()), 2) & Right(Year(Date()), 2)

            Comment

            • u2cannv
              New Member
              • Oct 2007
              • 5

              #7
              Originally posted by Rabbit
              In the filename field, you put:
              Code:
              ="C:\desktop\johndoe" & Right("0" & Month(Date()), 2) & Right("0" & Day(Date()), 2) & Right(Year(Date()), 2)
              Thanks a lot, finally got the code working. I really appreciate it.

              Comment

              • Rabbit
                Recognized Expert MVP
                • Jan 2007
                • 12517

                #8
                Not a problem, good luck.

                Comment

                Working...