Results 1 to 13 of 13
  1. #1
    aspen is offline Competent Performer
    Windows Vista Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    127

    Talking Save database as text and load database as text. Load Files from text not working

    Hi All I am getting errors while calling a function. Please see the link.


    http://gainingaccess.net/GainingAcce...SaveAsText.htm
    Its a code to export and import database as test files. I pasted the full codes on top of my code window And put this code behind one button to call export
    Public Function SaveDBAsText(strPath As String) As Boolean

    Code:
    Call SaveDBAsText("C:\Users\Shiham\Desktop\New\Import")
    . And it works fine. But when I call import function.

    Function LoadFilesFromText(strFolder As String, Optional blnIncludeSubfolders As Boolean)

    Code:
    Call LoadFilesFromText("C:\Users\Shiham\Desktop\New\Import\Test-accdb_2014-03-23-20-36\Forms", True)
    This just one of the ways I tried. But It doesn't work
    Can some one please see what I am doing wrong. or there is a problem with the code in the link
    Thanks you all

  2. #2
    Xipooo's Avatar
    Xipooo is offline Sr. Database Developer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Arizona
    Posts
    332
    What is the error you are getting? What line is highlighted when you go into debug mode?

  3. #3
    Xipooo's Avatar
    Xipooo is offline Sr. Database Developer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Arizona
    Posts
    332
    I already see one problem....

    Code:
    Application.LoadFromText acQuery, strObjName, strFilePath
    This is the only "LoadFromText" command you have and it is only loading queries. But when the script comes across any of the text files containing a Form, Module, Report, etc... it will error out since they will not be in for form of a text file for queries.

  4. #4
    aspen is offline Competent Performer
    Windows Vista Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    127
    Thanks Xipoo. I thought the code included the function to do them all. Here is the erro I get.
    Attached Thumbnails Attached Thumbnails Error.png  

  5. #5
    aspen is offline Competent Performer
    Windows Vista Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    127
    Thanks It works when I use your method
    Application.LoadFromText acQuery, strObjName, strFilePath
    But when I change Application.LoadFromText acTable, strObjName, strFilePath. Ac table it gives an error. " the object type augument for the action is blank or in valid.

  6. #6
    aspen is offline Competent Performer
    Windows Vista Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    127
    sorry I reposted thinking it was not posted. I guess there is no delete option for posts. any way sorry for that
    thanks

  7. #7
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,863
    Is the topic of this thread related to the other thread you started here?
    https://www.accessforums.net/program...der-42505.html

  8. #8
    Xipooo's Avatar
    Xipooo is offline Sr. Database Developer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Arizona
    Posts
    332
    Just changing it to acTable won't solve your problem. You need to have a way to make distinctions between the files you are importing. You can't import text files that hold Form data, Query Data, Report Data, Module Data, or Script data while you are using "acTable" because that is indicating to the LoadFromText command that the text file is of a Table format.

    If the text file contains a Form you need to use "acForm". If the text file contains a Report you need to use "acReport"... etc. Since you are passing in ALL TYPES of text files, you need to build your function to know which kind of text file it is so that your function changes from "acTable" for Table files, "acForm" for Form files, "acReport" for Report files... etc.

  9. #9
    aspen is offline Competent Performer
    Windows Vista Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    127
    Thanks Itsme And Xipooo. sory I responded late. When Its day there Its Night to my place. Well yes ItsMe. Its related to That Thread too. It works On all files accept for tables.And Load from file doesn't work with the code in My first top Posts link For Any files wheather its form report or table. AS zipoo pointed for tables it has to be different. something like this maybe
    DoCmd.TransferText acImportDelim, "FasTrakSpec", _

    Thanks

  10. #10
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,863
    In the other thread I mentioned that I would work on your question. I posted a DB there that I created specifically because you asked for help. The DB addresses the issue with the function mentioned here. The file I posted still needs some additional work, but I would rather address those issues in the other thread.

  11. #11
    Xipooo's Avatar
    Xipooo is offline Sr. Database Developer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Arizona
    Posts
    332
    aspen, I would suggest you focus on the other thread. ItsMe has put in a lot of time and effort to answer your question there.

  12. #12
    aspen is offline Competent Performer
    Windows Vista Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    127
    Sorry I have been there already and replied. I am sorry I couldn't Attend that all tough Its all done for my personally requesting because I have been concentrating on this. Thanks a lot. so I will type a link here to that thread so we can swthch easily https://www.accessforums.net/program...05/index2.html
    Thanks

  13. #13
    aspen is offline Competent Performer
    Windows Vista Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    127
    I guess Importing tables To Database saved as text Files is risky Difficult and not advisables. If any one have been doing it Please share. Thank you

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 02-12-2014, 12:13 PM
  2. Replies: 7
    Last Post: 03-12-2013, 07:18 PM
  3. Clear text box on form load
    By RoyLittle0 in forum Access
    Replies: 3
    Last Post: 03-05-2013, 05:40 AM
  4. Replies: 2
    Last Post: 03-01-2012, 12:21 PM
  5. Change the text box color on form load
    By mikec in forum Programming
    Replies: 2
    Last Post: 03-01-2010, 11:47 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 - Senior Forums