The code below is placed in a button control in ms access 2007 (using vba), however the above error message is returned at the set rst = db.openrecordset(strSQL, OpenSynaset) line. I am struggling with this for some time, but no solution yet. Any help is appreciated.
Thanks.
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim rst1 As DAO.Recordset
Dim strSQL As String
Dim strSQL1 As String
Set db = CurrentDb()
strSQL = "SELECT * FROM Table1 WHERE Table1.Project_Number=" & Me.PROJECT_NUMBER
Set rst = db.OpenRecordset(strSQL, OpenDynaSet)
If rst.RecordCount > 0 Then
strSQL1 = "SELECT * FROM Table2 WHERE Professional_REG_Number = " & rst(PROFESSIONAL_REG_NUMBER)
With rst1
If Not (.BOF And .EOF) Then
.Edit
.Delete
.Update
End If
.Close
End With
Set rst1 = Nothing
Else
'Do Nothing
End If
With rst
If Not (.BOF And .EOF) Then
.Edit
.Delete
.Update
End If
.Close
End With
Set rst = Nothing
'====================================ERROR HANDLING===========================================================
Exit_Delete_Record_s__Click:
Exit Sub
Err_Delete_Record_s__Click:
MsgBox Err.Description
Resume Exit_Delete_Record_s__Click
End Sub
Thanks.
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim rst1 As DAO.Recordset
Dim strSQL As String
Dim strSQL1 As String
Set db = CurrentDb()
strSQL = "SELECT * FROM Table1 WHERE Table1.Project_Number=" & Me.PROJECT_NUMBER
Set rst = db.OpenRecordset(strSQL, OpenDynaSet)
If rst.RecordCount > 0 Then
strSQL1 = "SELECT * FROM Table2 WHERE Professional_REG_Number = " & rst(PROFESSIONAL_REG_NUMBER)
With rst1
If Not (.BOF And .EOF) Then
.Edit
.Delete
.Update
End If
.Close
End With
Set rst1 = Nothing
Else
'Do Nothing
End If
With rst
If Not (.BOF And .EOF) Then
.Edit
.Delete
.Update
End If
.Close
End With
Set rst = Nothing
'====================================ERROR HANDLING===========================================================
Exit_Delete_Record_s__Click:
Exit Sub
Err_Delete_Record_s__Click:
MsgBox Err.Description
Resume Exit_Delete_Record_s__Click
End Sub