473,385 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to get external data into a table/form

I almost hate to ask this, it's so trivial. I am writing some code to
read a text file and place certain records (based on key words in the
file) into a form and table. I have the code written that reads the
text-file and parses out the keywords. What I can't remember (and all
my books are at home at the moment) is how to get the data into my
table and ultimately into my form.

Can someone point me to a code snippet someplace ? I sure would
appreciate it as I don't do this very often and just can't remember
the syntax.

TIA
Bill W
Nov 13 '05 #1
3 7218
bw******@lucent.com (Bill W.) wrote in message news:<c3**************************@posting.google. com>...
I almost hate to ask this, it's so trivial. I am writing some code to
read a text file and place certain records (based on key words in the
file) into a form and table. I have the code written that reads the
text-file and parses out the keywords. What I can't remember (and all
my books are at home at the moment) is how to get the data into my
table and ultimately into my form.

Can someone point me to a code snippet someplace ? I sure would
appreciate it as I don't do this very often and just can't remember
the syntax.

TIA
Bill W


Whoa. Tables *store* data. Forms are for people to read/modify/enter
data into a table. Or are you automating data entry somehow here?

If you have code that reads and parses text file, why not just create
an append-only recordset and write your data straight to the table?
Is there a reason you need the form? (Well, except for indicating to
the user that "yes, my code is running. Please do not turn this
computer off!")

Look up the .AddNew method in the help. You may have to open a module
so you can get to the VBA help. There are tons of examples there. If
you're writing through to a linked SQL Server table, use ADO,
otherwise, it doesn't matter - you can use DAO.
Nov 13 '05 #2

The easiest thing to do is to create a data pickup table with one field
- a memo field so that it doesn't matter how much data is in one row of
data from your text file. Then read the data in like this:

Dim TextLine as String, RS As Recordset

Set RS = CurrentDB.OpenRecordset("tblDataPickup")

Open "C:\Dir1\TESTFILE.txt" For Input As #1 'Open file.
Do While Not EOF(1) ' Loop until end of file.
Line Input #1, TextLine ' Read line into variable.
RS.AddNew
RS(0) = TextLine
RS.Update
Loop
Close #1 ' Close file.

The Line Input function reads one entire row at a time. Once the data
is in your table you can parse it much more easily using the Instr
function. Instr and Line Input are in the Access Help files.
Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3
You could try the Line Input Method for reading data from a text file.
The following example is based on an example from the Access Help Files.
Create a data pickup table that consists of just one field, a memo field
so that you don't have to deal with string size. You will be reading
each row of data in the textfile as one long string which you will parse
later inside of Access.

Sub GetTextFileData()
Dim MyString As String, MyNumber
Dim RS As Recordset
Set RS = CurrentDB.OpenRecordset("tblDataPickup")
Open "C:\dir1\Test1.txt" For Input As #1 ' Open file for input.
Do While Not EOF(1) ' Loop until end of file.
Line Input #1, MyString
RS.AddNew
RS(0) = MyString
RS.Update
Loop
Close #1 ' Close file.
End Sub

Then you can loop through the table and parse each field out based on
whatever the delimiter is - use Instr function.

HTH

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #4

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

Similar topics

4
by: Erohsik | last post by:
I am using external tables to load data from the data file. But the log files are getting created in the datafile's directory (because of CREATE OR REPLACE DIRECTORY ...) But I want those log...
4
by: intl04 | last post by:
How do I create a data input form in Access that is external to the Access database to which it's connected (if that's possible, which I believe it is)? For example, if someone clicks on an Access...
1
by: Aged | last post by:
Hi I have asked several groups now for advise but I feel I must be confusing either them or myself, but anyway here goes! Below is code taken from the "OnClick" function of a command button...
2
by: Sara | last post by:
Hi - I've been reading the posts for a solution to my query, and realize that I should ask an "approch" question as well. We receive our production data from a third party, so my uers import...
4
by: My SQL | last post by:
Hi Can I trigger an external program to run when a new record is added to the mysql table? The external program is in C and instead of scanning the table continuously for new insertions, it...
3
by: eieiohh | last post by:
MySQL 3.23.49 PHP 4.3.8 Apache 2.0.51 Hi All! Newbie.. I had a CRM Open Source application installed and running. Windows Xp crashed. I was able to copy the contents of the entire hard...
4
by: Adam Smith | last post by:
Hello, How can I call or trigger an external javascript twice in a form? I have <script language="JavaScript" src="country_state.js" name="Country_State"> <script type="text/javascript"...
0
debasisdas
by: debasisdas | last post by:
This thread contains some useful tips for using External tables. USING EXTERNAL TABLE ======================= 1.THE TABLE POINTS TO EXTERNAL FILE. IF DATA IS ALTERED IN THE EXTERNAL FILE,DATA...
3
by: tundal45 | last post by:
Hey Guys, I am trying to automate the process of loading data in our oracle server. As a part of that process, I am working on a perl script that loads external tables from data files. What I am...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.