Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Append Variable to Access Table

Status
Not open for further replies.

Rainbow17

Technical User
Nov 21, 2006
3
GB
Hi - I am a novice at Access and have what may be a basic problem. I have text files which I have imported in VB module and can manipulate to fit the fields of a table.
What I can't do is append these variables to a table. How can I do this?
 
What code do you have so far?

Ed Metcalfe.

Please do not feed the trolls.....
 
Hi Ed - Thanks for the interest.
The code I have simply reads in the text file. I can write code to chop the data and put into arrays - stored as strings ready to be appended to my Access table(s).
What I haven't been able to do is add code to store the strings in the table. As an eg I have a Result$(x) which I want to store in a Re_Result field in table Tbl_Results.
Does this help?
Thx Alec
 
Can you post the code? If I can see exactly what you have so far I can advise better on what is required to store the results in a table.

Ed Metcalfe.

Please do not feed the trolls.....
 
Hi Ed
Code as follows simply inputs data and then rewrites it to another file - but I want to store each line in an Access table;

Sub ReadInJ()
Close
Dim LineFromFile As String
Dim x As Integer, y As Integer
ReDim LineArray(0) As String
IsFirstLine = 1
Open "C:\Documents and Settings\Alec\My Documents\AE000400.res" For Input As #1
Open "C:\Documents and Settings\Alec\My Documents\TestJ.TXT" For Output As #2
Do Until EOF(1)
Line Input #1, LineFromFile
If IsFirstLine = 1 Then
LineArray(0) = LineFromFile
IsFirstLine = 0
Else
ReDim Preserve LineArray(UBound(LineArray) + 1)
LineArray(UBound(LineArray)) = LineFromFile
End If

Loop
For y = 0 To UBound(LineArray)
Print #2, LineArray(y)
Next y
Close #1
Close #2
End Sub
 
I have a Result$(x) which I want to store in a Re_Result field in table Tbl_Results
One way:
Code:
CurrentDb.Execute "INSERT INTO Tbl_Results (Re_Result) VALUES (" _
 & "'" & Replace(Result$(x), "'", "''") & "')"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top