I have been racking my brain on this one for days now. I have searched the posting but still can not find a solution.
I am using VB6 with Access 2000 to do a lookup to a DAO recordset using Findfirst. As long as the record exists everything works great. If the record is not in the recordset then the recordset goes empty and when I try and Addnew it give me "cancelled by associated object" error message. I have tried checking BOF and EOF but to no avail.
Here is the code....any help would be greatly appreciated!!
Check_ID:
searchstr = "ID = " & Val(add_stud_id)
stdDisp.student.Recordset.FindFirst searchstr
If stdDisp.student.Recordset.NoMatch Then
'If no student record then look up in cross reference file
searchstr = "student_id = " & Val(add_stud_id)
stdDisp.id_crs_tbl.Recordset.FindFirst searchstr
If stdDisp.id_crs_tbl.Recordset.NoMatch Then
If chk_cross.Value = 1 Then
'If no cross reference then create cross reference
'If creating a cross reference then get ID number
new_id = ""
valid_id = False
new_id = InputBox("Enter ID: ", "New ID")
'Make sure new ID does not already exist
GoTo Check_ID
At this point it would loop back to verify that ID does not already exists. If nomatch then it goes on to do an Addnew and gets and error.
I am using VB6 with Access 2000 to do a lookup to a DAO recordset using Findfirst. As long as the record exists everything works great. If the record is not in the recordset then the recordset goes empty and when I try and Addnew it give me "cancelled by associated object" error message. I have tried checking BOF and EOF but to no avail.
Here is the code....any help would be greatly appreciated!!
Check_ID:
searchstr = "ID = " & Val(add_stud_id)
stdDisp.student.Recordset.FindFirst searchstr
If stdDisp.student.Recordset.NoMatch Then
'If no student record then look up in cross reference file
searchstr = "student_id = " & Val(add_stud_id)
stdDisp.id_crs_tbl.Recordset.FindFirst searchstr
If stdDisp.id_crs_tbl.Recordset.NoMatch Then
If chk_cross.Value = 1 Then
'If no cross reference then create cross reference
'If creating a cross reference then get ID number
new_id = ""
valid_id = False
new_id = InputBox("Enter ID: ", "New ID")
'Make sure new ID does not already exist
GoTo Check_ID
At this point it would loop back to verify that ID does not already exists. If nomatch then it goes on to do an Addnew and gets and error.