error in recordset code

B

bob

When I am running these code it is giving me an error on
the db.execute line saying"
runtime error 3070. The Microsoft jet engine does not
recognise '00040' as a valid field name or expression"
can someone help?


Private Sub Command46_Click()

'below is ken's code.above is the test code to insert a
record in to the tbl attendance

Dim db As Database
Dim rs As Recordset
Dim strsQl As String

Set rs = Me.RecordsetClone
Set db = CurrentDb

rs.MoveFirst

Do Until rs.EOF



strsQl = _
"Insert into tblattendance(" & _
StudentClockNum & ") values(" & _
rs.Fields("StudentClockNum") & ");"

db.Execute strsQl 'dbFailOnError

rs.MoveNext
Loop
Set rs = Nothing
Set db = Nothing

End Sub
 
L

losmac

To find out what's going wrong with your sql statement use
MsgBox function. Watch (follow) your errors..
In your do while ... loop statement
strsQl = _
"Insert into tblattendance(" & _
StudentClockNum & ") values(" & _
rs.Fields("StudentClockNum") & ");"

'db.Execute strsQl 'dbFailOnError
Msgbox strsql
 

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