I have a continuous form that has two comboboxes where data in one is dependent on data in the other. The code I'm using is below - it occurs when focus is lost from the dependent combo. I can enter 2 records with no problem but when I enter the third, the form deletes all records in the form. When I debugged, it looks like when the code looks at the recordcount and goes into the if statement, on requery it's resetting the form to 0 records. I don't know why this would be happening.
Private Sub Error_ID_LostFocus()
Dim CurrentRecord As Variant
Dim strSQL As String
Dim dbThis As DAO.Database
Dim rstErrors As DAO.Recordset
If Me.Error_ID.Value = 0 Then
MsgBox "An Error Description is required.", , "Error Desc"
strSQL = "SELECT QM_Error_Definitions.Error_ID, QM_Error_Definitions.Error_Description AS [Error desc], " & _
"QM_Error_Definitions.Error_Capture_Vehicle_ID, QM_Error_Definitions.Error_Capture_Location_ID, " & _
"QM_Error_Definitions.Error_Capture_Building_ID, QM_Error_Definitions.[Error_Capture_Class/Cov], " & _
"QM_Error_Definitions.Error_Capture_Other_Source FROM QM_Error_Definitions INNER JOIN [QM_Error-Trans] ON " & _
"QM_Error_Definitions.Error_ID=[QM_Error-Trans].Error_ID " & _
"WHERE ((QM_Error_Definitions.Error_Exp_Date) Is Null) ORDER BY QM_Error_Definitions.Error_Description;"
Form_frmQM_MainReviewForm.frmQM_ErrorEntry.Form.Error_ID.RowSource = strSQL
Set rstErrors = Form_frmQM_MainReviewForm.frmQM_ErrorEntry.Form.Recordset
If rstErrors.RecordCount > 1 Then
CurrentRecord = Form_frmQM_MainReviewForm.frmQM_ErrorEntry.Form.Bookmark
Form_frmQM_MainReviewForm.frmQM_ErrorEntry.Form.Bookmark = CurrentRecord