Compile Error

Tina Brev

Registered User.
Local time
Today, 20:58
Joined
Oct 26, 2000
Messages
25
Hello!

I have a form that has a text box and when you double click on the text box, download will happen automatically from textfile but instead I keep getting a compile error / syntax error.

Can anybody figure out what is the syntax error in this code?. The line "On Error GoTo readAllFile ......." turns red.


Public Function readAllFiles(hdl As String)

On Error GoTo readAllFiles _Err

Dim tmp As String
Dim db As DAO.Database
Dim rs As DAO.Recordset

'Set a reference to the current database
Set db = CurrentDb()

'Asign a recordset to a variable
Set rs = db.OpenRecordset("tblData", dbOpenDynaset)


' Open the text file.
Open hdl For Input As #1

'Loop through the lines of text until the end of file
Do While Not EOF(1)
'Read the line into a variable.
Line Input #1, tmp
'Find the data, we use "Chr(34)" because it is the ASCII
'value for quote marks and if we use actual quote marks
'the written string would be used instead of the variable
rs.FindFirst "fldData = " & Chr(34) & Piece(tmp, ",", 1) & Chr(34)
If Not rs.NoMatch Then
rs.Edit
' update it
rs("fldData") = Piece(tmp, ",", 2)
rs.Update
End If
'Check for error 52
If Err = 52 Then
Close #1
End If
'Loop for next line
Loop

'Close the text file
'when your done
Close #1

Exit Function

readAllFiles _Err:
MsgBox Error$, 16, "Error"
Exit Function
End Function

Thank again in advance for your help!
 
If there is a space in:
readAllFiles _Err
take it out. That's my bet on what is causing the problem.
 
Hello Chris,

Once again thank you very much for the suggestion. Exactly right. The "space" was the error.

Happy Friday and have a good weekend!
wink.gif
 

Users who are viewing this thread

Back
Top Bottom