Hi all,
I have a form that has two unbound list boxes, I then have a command button which is supposed to write a record two a table when clicked. The table has three fields, a Primary key (autonumber) Then two foreign key fields, which the two list box values should populate. I have the following code attached to the button:
Private Sub Command3_Click()
On Error GoTo Err_Command3_Click
Dim dbAssesmentTool As DAO.Database
Dim rstAssesment As DAO.Recordset
Set dbAssesmentTool = CurrentDb
Set rstAssesment = dbAssesmentTool.OpenRecordset("tblAssessmentlink")
rstAssesment.AddNew
rstAssesment("AssessmentID").Value = AssessmentName
rstAssesment("SiteID").Value = SiteName
rstAssesment.Update
Exit_Command3_Click:
Exit Sub
Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click
End Sub
On clicking i get an "Item not found in this collection" message... I don't know whats going on, I use the same code for another function and it works fine. can anyone please help???
TIA
mayday
I have a form that has two unbound list boxes, I then have a command button which is supposed to write a record two a table when clicked. The table has three fields, a Primary key (autonumber) Then two foreign key fields, which the two list box values should populate. I have the following code attached to the button:
Private Sub Command3_Click()
On Error GoTo Err_Command3_Click
Dim dbAssesmentTool As DAO.Database
Dim rstAssesment As DAO.Recordset
Set dbAssesmentTool = CurrentDb
Set rstAssesment = dbAssesmentTool.OpenRecordset("tblAssessmentlink")
rstAssesment.AddNew
rstAssesment("AssessmentID").Value = AssessmentName
rstAssesment("SiteID").Value = SiteName
rstAssesment.Update
Exit_Command3_Click:
Exit Sub
Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click
End Sub
On clicking i get an "Item not found in this collection" message... I don't know whats going on, I use the same code for another function and it works fine. can anyone please help???
TIA
mayday