Importing data from HTML Forms into Access

G

Guest

How would you go about importing HTML Form data into an Access database?

The server script that processed the data created a log file on the server
that looks like this, but with many more entries:

Name: Fred Flinstone
Address: 123 Main Street
City: Los Angeles
State: CA
Zip: 91700
######
Name: Captain Kangaroo
Address:
City: Hollywood
State: CA
Zip: 91705
######
Name: George Bush
Address: 1600 Pennsylvania Avenue NW
City: Washington
State: DC
Zip: 20500
 
B

Brendan Reynolds

Public Sub ImportLog()

Dim intFile As Integer
Dim strLine As String

Dim strFieldName As String
Dim strFieldValue As String

Dim db As DAO.Database
Dim rst As DAO.Recordset

Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT * FROM tblTest", dbOpenDynaset,
dbAppendOnly)

intFile = FreeFile
Open CurrentProject.Path & "\TestLog.txt" For Input As intFile
rst.AddNew
Do Until EOF(intFile)
Line Input #intFile, strLine
If strLine <> "######" Then
strFieldName = Left$(strLine, InStr(1, strLine, ":") - 1)
strFieldValue = Mid$(strLine, InStr(1, strLine, ":") + 1)

'Other field names are the same as the headings in the text
file,
'but 'Name' is a reserved word, so used 'FullName' instead.
If strFieldName = "Name" Then
strFieldName = "FullName"
End If

rst.Fields(strFieldName) = strFieldValue
Else
rst.Update
rst.AddNew
End If
Loop
Close intFile
rst.Update
rst.Close

End Sub
 

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

Top