+ Reply to Thread
Results 1 to 2 of 2

Data Request with ADO - Problem with txt File

  1. #1
    Registered User
    Join Date
    11-09-2008
    Location
    Frankfurt, Germany
    Posts
    1

    Data Request with ADO - Problem with txt File

    Dear All,

    Drawing on my VBA book and various example codes in the internet I have put together a VBA code which retrieves data from a txt file. This works absolutely fine as long as I only try to request numbers. I am running into problems, however, when I want to retrieve fields which contain text.

    Actually, my problem is even more complicated in a sense that my code works in some cases (e.g., with one txt file which I have simplified by deleting some columns and rows in order to find the mistake) and does not in others (e.g., with a file which is more similar to those which I have to analyse) while I cannot find any regularity / reason for that.

    In the following you can find the VBA code with which I retrieve the data from the txt file. The request is started with the last procedure (“TestRequest“). Additionally, I have attached 4 files (in one zip file): First, you can find the files Beispiel.txt and Schema.ini. Using the code below together with these two files (they have to be saved in the same folder like the workbook which contains the code) works properly. Second, you can find the files Test.txt and Schema2.ini (the name of the last one needs to be changed to Schema.ini). When I replace the file name in the last procedure (“Test Request”) the code should work for this txt file, too………. but it does NOT. I just get an error message (which I have translated in English by myself, hopefully it becomes clear):
    „Runtime error: ‘3021‘: Either BOF or EOF is True, or the current dataset has been deleted.“

    I have already tried out everything I can think of and I am now running out of ideas… What is the problem, what am I doing wrong in the case of the Test.txt file? – I would be more than happy for any reply which could help to find the error.

    Just as a remark – the SQL request is of course not very sophisticated and does not make a lot of sense; I have simplified as far as possible in order to find the mistake.

    Best regards
    JapanFreak

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by VBA Noob; 11-09-2008 at 10:21 AM.

  2. #2
    Registered User
    Join Date
    10-04-2008
    Location
    uk
    Posts
    26
    Hi

    this might work.

    In Schema.ini simply have

    [test.txt]
    Format=Delimited(^)
    ColNameHeader=True

    then try the following code

    Please Login or Register  to view this content.

    regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1