read from file and insert data to form

M

Maya

Hi.

I have txt file at c:\. I need to scan every row and insert it to form.
the form include sub form and button submt, when I click submit I call to
function that read from the file line by line, and insert data to the form.
it parse any line when she get to'#'
for example:
c:\phone.txt
123#david smith#London#54545
231#Sara Kermer#NY#98975

the form table is:
phone_id|name|zip_code

I was trying to write it in loop, so if I'll add column into the table (and
to the file in proper) - it will be much easier,
can anyone help?
Thanks.
 
D

Douglas J. Steele

Something like the following untested air-code:

Dim intFile As Integer
Dim strBuffer As String
Dim strFile As String
Dim varValues As Variant

strFile = "C:\phone.txt"

' Check to make sure the file exists
If Len(Dir$(strFile)) > 0 Then
intFile = FreeFile
Open strFile For Input As #intFile
' Loop until end of file.
Do While Not EOF(intFile)
' Read current line in file into buffer.
Line Input #intFile, strBuffer
varValues = Split(strBuffer, "#")
' At this point, varValues(0) will contain the phone_id,
' varValues(1) will contain the name and so on.
' Do something with it, and then see whether there's
' anymore data to read.
Loop
Close #intFile
End If


HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

help parsing file into form 1
file problem 0
SQL insert data from another DB 6
Load data from Word into Excel 7
no errors- no input 0
PLEASE HELP, insert 0
Create a txt file from access 2
insert problems 1

Top