I have a button on a Client form that opens a form with a query as filter. If the query filters no records then the form comes up blank and doesnt even show the close button. Im trying to use code to say if the query count is 0, which is -1 right?, then do not open the form and say a msgbox 'No skills to delete'. My code is below, i keep fiddling with the code but get different errors. the latest error is run time error 424, object required. can anyone help me please to achieve this, below is my code:
Private Sub btnDelSkillCJ_Click()
Dim myCount As Variant
DoCmd.OpenForm "frmCandSkillsDel", acNormal, "qryCandSkillFilter", , , acDialog
myCount = Selection.Rows.Count
If myCount = -1 Then
DoCmd.Close acForm, "frmCandSkillsDel"
End If
End Sub
Regards,
Charles
PS I also need to do something similar when the form comes up and i use the delete button to delete the last record (which makes the form go blank) to close the form with a msg saying 'No more skills to delete'