Thanks again
Let me digress here and give you the details.
I have an application called Student Training System which
is basically used by the mechanics/technicians etc as part
of their ongoing training which is computer based.
I am doing an enhancement whereby the Supervisor of this
program is able to exempt all the students for a
particular week such as Xmas etc.
I have a table called tblstudents which has all the
information about the students and the individual
schedules.
The only thing that I have to calculate on the fly is the
noumer of hours for each student,Thours field which is
basically a product of the number of sched seesions and
the sched hours for each session. What I am doing is I am
taking all these information and putting it on to a form.
Now, at any given time each student maybe in diffrent
program eg M11,G12 etc but That information comes from a
different table and I am assuming that the supervisor will
just give the exemption on a dummy program call T11 and a
dummy course num of 25.
Now everytime a student attends a session a record of that
is created in the tblattendance table and this includes...
Student clock number,Prog code,CoursNumber,Login
Time,Logout time,Exempt,Hours attended.
Of which the Stud clock num,prog code,course num,login
time,are all part of the pkey and hence they must be
filled at all times.
So I am creating a form..part of the data on that form
coes from this tblstudents. Then on that form I am adding
text fields for the super to add like Prog code,Course
num,Login time,Exempt all,Hours and when the user enters
these values..for each student record these values get
filled in.
I want to insert all the 7 fields
Student clock number,Prog code,CoursNumber,Login
Time,Logout time,Exempt,Hours attended.
in to the tblattendance. As long as the student clock num
and the Thours fields have the correct value evrything is
fine. The students are graded according to the fact that
well they took 4 hrs to complete a 3 hr course etc. and a
number of reports run of the tblattendance.
Now since the data is coming from the tblstudents, new
fields are added and the destination table is different I
had to create a recordset clone.
When I am running the code below I am getting the
following error....
Run-time error "3265"
Item not found in this collection.
The message says...
An attempt to reference a name in a collection failed.
Possible causes:
1)the object doesn't exist in this collection. Make sure
that the object is appended to collection before
referencing it.
2)There is more than one object with this name in this
collection; using its name with this name is an ambiguous
reference. reference the object by its original position
in the collection for e.g.. recordsets(3)).
Code..........
private sub command 46_click()
Dim rs As DAO.Recordset
Dim db As DAO.Database ' for insert queries
Dim strsql As String
Set db = CurrentDb
Set rs = Me.RecordsetClone
With rs
If .RecordCount <> 0 Then .MoveFirst
Do Until .EOF
strsql = _
"INSERT INTO tblAttendance " & _
"(StudentClockNum, ProgramCode,
CourseNum, " & _
"LoginTime, Exempt, SHours) " & _
"VALUES (" & _
"'" & !studentclocknumber & "', " & _
"'" & !ProgCode & "', " & _
"'" & !CNum & "', " & _
Format(!Login, "\#mm/dd/yyyy
hh:nn:ss\#") & ", " & _
!Check54 & "," & _
!THours & ")"
' Uncomment if needed for debugging:
Debug.Print strsql
db.Execute strsql, dbFailOnError
.MoveNext
Loop
End With
Set rs = Nothing
Set db = Nothing
End Sub