unbound fields recordset error

B

bob

I am getting closer. Now the error I am getting is
that ....at line db.execute...

and the error is runtime'3061'
Too few parameters . Expected 1.


Also, my question is I am not doing anything wrong here in
creating the recordset right? I mean I can createa
Recordset from a form where some fields are bound and the
others are unbound.

For my fields....

Studentclocknum is text
Shours is numbers
programcode is text
cnme is text
logintime is date
logout is date
exempt is a text...a check box?


my syntax is right?



Private Sub Command46_Click()


Dim db As DAO.Database
Dim strsql As String

Set db = CurrentDb

With Me.RecordsetClone

..MoveFirst

Do Until .EOF

'begin of the insert statement to insert the records

strsql = _
"Insert into tblattendance " & _
"(StudentClockNum,programcode,coursenum,exempt,
shours) " & _
"Values (" & _
.Fields("StudentClockNum") & ", " & _
Me!ProgCode & ", " & _
Me!CNum & ", " & _
Me!Check60 & "," & _
.Fields("thours") & _
");"

db.Execute strsql, dbFailOnError

..MoveNext
Loop
End With


Set db = Nothing

End Sub
 
S

Scott McDaniel

strsql = "Insert into
tblattendance(StudentClockNum,programcode,coursenum,exempt,shours) Values('
" & _
.Fields("StudentClockNum") & " ', ' " & Me!ProgCode & " ', ' " & Me!CNum
& " ', " & Me!Check60 & "," & .Fields("thours") & ")"

You must surround text fields with quotes and date fields with # signs ...
note also that I've included some spaces around the single quotes so that
you can see them, but you should remove the spaces before running the
statement.
 

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