I keep getting a "Item not Found in Collection" error when I try to AddNew to the database.
It hangs up on:
"If txtGrade.Text <> "" Then
.Fields("tblStudentLog.Grade"
= txtGrade.Text
End If"
The only thing I can figure out is Grade is the first item that is NOT in BOTH databases. StudentNo, Date, StaffNo, SchoolNo ALL exist in BOTH databases. Once I try and add Grade, it returns the "Item not Found in Collection" error. I have StudentLogNo as the Primary Key in the tblStudentLog table and I have StudentLogNo as a foreign key in the tblLog table. They have a one to many relationship.
Private Sub cmdSave_Click()
Dim rsSave As DAO.Recordset
Dim Response
Dim I As Integer
Set rsSave = dbWrap.OpenRecordset("SELECT tblStudentLog.*, tblLog.* " & _
"FROM tblStudentLog INNER JOIN tblLog ON tblStudentLog.StudentLogNo=tblLog.StudentLogNo"
With rsSave
.AddNew
If txtStudentNo.Text <> "" Then
.Fields("tblStudentLog.StudentNo"
= txtStudentNo.Text
End If
If txtGrade.Text <> "" Then
.Fields("tblStudentLog.Grade"
= txtGrade.Text
End If
If dtpDateLog.Value <> "" Then
.Fields("tblLog.Date"
= dtpDateLog.Value
End If
If txtStaffNo.Text <> "" Then
.Fields("tblStudentLog.StaffNo"
= Suser
End If
If cboSchool.Text <> "" Then
.Fields("tblStudentLog.SchoolNo"
= cboSchool.ItemData(cboSchool.ListIndex)
End If' If txtComment.Text <> "" Then
.Fields("tblStudentLog.Comment"
= txtComment.Text
End If
If txtGAFScore.Text <> "" Then
.Fields("tblStudentLog.GAF"
= txtGAFScore.Text
End If
If txtAmountOfTime.Text <> "" Then
.Fields("tblStudentLog.AmtOfTime"
= txtAmountOfTime.Text
End If
.Update
End With
MsgBox "Save successful!", vbInformation
Unload frmSearch
Unload Me
End Sub
It hangs up on:
"If txtGrade.Text <> "" Then
.Fields("tblStudentLog.Grade"
End If"
The only thing I can figure out is Grade is the first item that is NOT in BOTH databases. StudentNo, Date, StaffNo, SchoolNo ALL exist in BOTH databases. Once I try and add Grade, it returns the "Item not Found in Collection" error. I have StudentLogNo as the Primary Key in the tblStudentLog table and I have StudentLogNo as a foreign key in the tblLog table. They have a one to many relationship.
Private Sub cmdSave_Click()
Dim rsSave As DAO.Recordset
Dim Response
Dim I As Integer
Set rsSave = dbWrap.OpenRecordset("SELECT tblStudentLog.*, tblLog.* " & _
"FROM tblStudentLog INNER JOIN tblLog ON tblStudentLog.StudentLogNo=tblLog.StudentLogNo"
With rsSave
.AddNew
If txtStudentNo.Text <> "" Then
.Fields("tblStudentLog.StudentNo"
End If
If txtGrade.Text <> "" Then
.Fields("tblStudentLog.Grade"
End If
If dtpDateLog.Value <> "" Then
.Fields("tblLog.Date"
End If
If txtStaffNo.Text <> "" Then
.Fields("tblStudentLog.StaffNo"
End If
If cboSchool.Text <> "" Then
.Fields("tblStudentLog.SchoolNo"
End If' If txtComment.Text <> "" Then
.Fields("tblStudentLog.Comment"
End If
If txtGAFScore.Text <> "" Then
.Fields("tblStudentLog.GAF"
End If
If txtAmountOfTime.Text <> "" Then
.Fields("tblStudentLog.AmtOfTime"
End If
.Update
End With
MsgBox "Save successful!", vbInformation
Unload frmSearch
Unload Me
End Sub