Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    alyon is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2011
    Posts
    89

    PLEASE HELP Send Report to MkDir Path

    Hello,
    I figured out how to create a new folder through the MkDir function, but my problem is, I then need my report to go to the new folder I just created.

    For example:
    the path is = "\\VAIO\Users\Documents\Township\" & Me.[Owner Name].Value

    when I try to send the report there.. it only goes to "\\VAIO\Users\Documents\Township\" and not the new folder created titled with the owner name... the Me.[Owner Name].Value ends up getting set as the name of my report, in addition to the report name which is defined as the number.



    My actual code is listed below:

    Private Sub cmdFileReceipt_Click()
    Dim strMyPath As String
    If Me.cboMun.Value = "C-Town" Then
    strMyPath = "\\VAIO\Users\Documents\C-Town\" & Me.[Owner Name].Value
    End If
    If Me.cboMun.Value = "O-Town" Then
    strMyPath = "\\VAIO\Users\Documents\O-Town\" & Me.[Owner Name].Value
    End If
    If Len(Dir(strMyPath, vbDirectory)) = 0 Then
    MkDir strMyPath
    End If

    Dim strMyName As String
    strMyName = "Receipt" & Me.txtNumber.Value


    DoCmd.OpenReport "File Current Permit", acViewPreview, , "[ID] = " & Me.[ID]
    DoCmd.OutputTo acOutputReport, "File Current Permit", acFormatPDF, strMyPath + strMyName, False
    DoCmd.Close acReport, "File Current Permit"
    End Sub

    Thank you for all your help!!!
    A. Lyon

  2. #2
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    Is this correct?

    I think that you may also be missing a backslash at the end of your path.

  3. #3
    alyon is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2011
    Posts
    89
    Would you put a backslash after the Me.[Owner Name].Value? Where else would I be missing it?

  4. #4
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    That's where I thought the backslash was missing.

    Quote Originally Posted by alyon View Post
    Would you put a backslash after the Me.[Owner Name].Value? Where else would I be missing it?
    If you still have a directory error, use either debug.print or a msgbox to look at the path and file name that is being generated.

  5. #5
    alyon is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2011
    Posts
    89
    I know what path is being generated, and I don't have an error. It's just not doing what I want. It's not registering the & Me.[Owner Name].Value part, it's going through the direct path. I need to know how to make it add & Me.[Owner Name].Value into the directory path.

  6. #6
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    Have you traced the execution?

    Specifically, is the MKDIR being executed?

  7. #7
    alyon is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2011
    Posts
    89
    Yes. It creates a new folder with no problems. The problem is the record does not go into the just created folder, it instead goes beside it.

  8. #8
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    Please post your last code snippets.

    I just realized that I may no longer be tracking your changes.

  9. #9
    alyon is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2011
    Posts
    89
    I don't understand how you're not tracking my changes. I haven't made any changes! I still have the code I had in my orginal post. All your questions could have been answered by reading that.

    I just need to get my report to file into the folder I create through the mkdir function. The MkDir works Just Fine, but when trying to file my report into the just made folder, it doesn't register the & Me.[Owner Name].Value as part of the path, it instead sends it through the specified path in "" and adds Me.[Owner Name].Value to the Name it saves the report as. That is all I need fixed. My command and MkDir have always worked just fine, I've never had any runtime errors, it just doesn't place it where I want.

  10. #10
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    Your response cleared up one question.


  11. #11
    alyon is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2011
    Posts
    89
    That doesn't help me? The issue is not the order or anything involving the MkDir... maybe that's what is confusing and I should have never included it in my post...

    The issue is I cannot get my current record to file into a path such as
    strMyPath = "\\VAIO\Users\Documents\C-Town\" & Me.[Owner Name].Value
    because & Me.[Owner Name].Value does not register in the path, only \\VAIO\Users\Documents\C-Town\ does, which is why it files it there.

    If it were to say \\VAIO\Users\Documnets\C-Town\Smith I would have no issues, except that I never know what the name is going to be to define it in the path.

  12. #12
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    I understand that the MKDIR in your code creates a directory with the

    proper name. I also understand that a file with the proper name is being written to the root of the directory which you are creating. I believe you said that you could write the file to any preexisting directory.
    That suggests to me that the link is relevant, i.e. Access "calls" Windows to create a directory, and then while Windows is making the directory, Access has already written the file ...to the root directory. I would have expected an error, but since you aren't getting one, I'd guess that if you put a msgbox or pause after the MKDIR, your file might be written correctly.

  13. #13
    alyon is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2011
    Posts
    89
    I get what you're saying, the link you posted kind of explained the same thing... so I tested that idea after reading the link...

    I deleted the MkDir part of the code, to see if it was just because it was busy... but even with the MkDir deleted, and the folder already made when I opened access... it still did the same thing..

    It has nothing to do with being busy....

    It's because when you write code for a report to go into a file you have to state a certain path, and it's not understanding the folder name of the textbox value... and only goes through the already specified path...

    ..I've known what's wrong.. I just need to know how to fix it. :/

  14. #14
    alyon is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2011
    Posts
    89
    And just to double check... I added your msgbox... it doesn't change anything.. the same thing that has happened, continues to happen.

  15. #15
    alyon is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2011
    Posts
    89
    I know the issue is in the path.. and I don't know how to make & Me.[Owner Name].Value part of the path?

    I tried clarifying the path to:
    "\\VAIO\Users\Documents\Township\ & Me.[Owner Name].Value\"

    and that made a folder literally named "& Me.[Owner Name].Value" and filed the reciept in there like its supposed to....

    but I need the actual owner name to be the title of the folder, not the code for the value of the owner name textbox.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Send Report to a NEW file
    By alyon in forum Access
    Replies: 9
    Last Post: 12-06-2011, 12:57 PM
  2. Help Send Report to File.
    By alyon in forum Access
    Replies: 4
    Last Post: 08-22-2011, 10:37 AM
  3. Send Report and Attachments in Email
    By Pimped in forum Programming
    Replies: 1
    Last Post: 06-21-2011, 02:51 AM
  4. send object report
    By ldappa in forum Access
    Replies: 1
    Last Post: 07-19-2010, 10:10 AM
  5. Send Primary Key from a Form To A Report
    By nkuebelbeck in forum Forms
    Replies: 1
    Last Post: 03-18-2010, 12:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums