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
Bookmarks