473,803 Members | 3,899 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

import a textfile with vba

Hello,

I'm trying to import a textfile into an Access table. I want
to write a macro to do all the work automatically.

My textfile looks like that:
artNr;descripti on;sellingValue
111111;top;0.34

The different colums are divided by ";" and the sellingValue is a
double datatype which is divided by ".".

I want to to create a table that looks like that:
artNr description sellingValue
111111 top 0,34

--------------
Datatypes:
artNr = text
description = text
sellingValue = double

Thanks a lot,
Mibi
Nov 13 '05 #1
4 5297
HJ
There are several ways to do this. One is to use the Open and Input
commands, e.g.

Open YourTextFile.tx t For Input As 1

For each line: Input #1, strInput until you meet an empty line (strInput="")
or error 62 (end of file).

Then you can split each line by searching for the ; characters.

HJ

<mi******@gmx.d e> wrote in message
news:77******** *************** ***@posting.goo gle.com...
Hello,

I'm trying to import a textfile into an Access table. I want
to write a macro to do all the work automatically.

My textfile looks like that:
artNr;descripti on;sellingValue
111111;top;0.34

The different colums are divided by ";" and the sellingValue is a
double datatype which is divided by ".".

I want to to create a table that looks like that:
artNr description sellingValue
111111 top 0,34

--------------
Datatypes:
artNr = text
description = text
sellingValue = double

Thanks a lot,
Mibi

Nov 13 '05 #2
Hmmmm, sounds like your looking to hard for the answer, search the
access help for the DoCmd.TransferT ext command, this will import or
export text files fairly simply.
Nov 13 '05 #3
use TransferText and create an import specification. Much easier.
Nov 13 '05 #4
Just go file->get external data, and follow the wizard.

You should be able to import this data with no code at all. The import
ability of ms-access is quite good, and likely you don't need any code here.
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl************* ****@msn.com
http://www.attcanada.net/~kallal.msn
Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2547
by: Larry Rekow | last post by:
I have a report that's created each day as a flat textfile. Because I came from the Access world, I created a macro that imports it with a schema that gives meaningful names to the various columns, and then uses a query to massage some of the data for me (deletes the first blank row and does a couple of calculations) Then I use DTS to import the Access query as a table. the textfile has a column called "File_num", and among several...
3
3672
by: Elaksomfan | last post by:
Hi, I am having trouble importing data from an excel spreadsheet into MS SQL Server 2000 using DTS Wizard. The DTS import process is successfull, no errors, but only 50 rows of approx. 1500 rows of data are imported. I tried to remove 20 rows in the excel spreadsheet in the interval row 0-50. When i later ran the import, only 30 rows were imported. I deleted almost every row in the interval 0-50, with the result of the import having 0...
2
455
by: Sigurd Bruteig | last post by:
Hi all! With the transferText method I have made a routine that import a textfile to a table.The textfile is a pricelist from the supplier. The problem is that the supplier uses . (dot) as descimal point, but the standard desimal point is , (comma). How do i change the desimal point, without any user action. Is it possible to do this in a query? Sigurd --
1
3784
by: ghadley_00 | last post by:
Hi, I have a MS access database table for which I regularly need to import fixed width text data. At present I have to to cut and paste the text data from its source to a text file, save the file, import the text file as fixed width text , and then run an update query to copy the appropriate info into fields of a different table. Is it possible to write a macro to do all these steps? Also, is it
1
11246
by: Supersonic | last post by:
I’m a dba for a SQL and I’m trying to learn how to import data from a simple text file. The text file looks like "1, name" "2, name2" and so on. How is it possible to solve this import with python? It’s no problem to connect to the database and do some insert and select statement. It is when I put the read from text file and then insert this data to the database I got problem. One script I have tried looks like this: import pymssql import...
1
2621
by: joel.sjoo | last post by:
I'm a dba for SQL server and I Will import a textfile to SQL. For example I use a file with 3 columns. ID, Name and Surname and the columns are tab separated. I don't know much about programming. Anyway, I use this code below. It works, but it will not split the columns. I have tried to change the argumnts in str(alllines) Some of the columns can include many characters and some not. For exampel names can be Bo or Lars-Ture. I be glad...
2
1836
by: arunaksha7 | last post by:
I am new to ASP.NET. I am facing a problem to import contents of a textfile to my ASP.NET Web Application datagrid.
9
5792
by: a | last post by:
Dear friends I want import data from CSV file to mdb file How can I do that in vb.net?
5
3166
by: kashif73 | last post by:
I have a text file with hundreds of records. each line contain 1250 values seperated by a semicolon. I have created 2 tables in SQL server 2000, one with 1000 columns & the second with 250 columns. my question is how can i import this textfile in to these 2 tables.and how i ensure that first 1000 values go to first table & the rest 250 in the next from each line of the text file. can be this be done via VB.NET or ASP? I would be grateful for...
0
9564
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10310
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10292
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9121
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6841
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5498
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4275
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.