Hi, I'm new to VBA coding and self-taught on everything I know. I'm trying to build a simple database for tracking accounts ordered through a third party. I have a Form which opens a Query, but when the query returns nothing I want it to display a MsgBox asking if the user wants to search again. I am using DCount however I am getting a runtime error 2465 with the following code:
I appologise if my code is really bad.
Code:
Private Sub Form_Load()
Dim intCount
DCount intCount, [Queries]![sign_syops]![mt_surname]
If intCount = 0 Then
strMsgBox = MsgBox("No results found. Search again?", vbYesNo, "Error!")
If strMsgBox = 6 Then
DoCmd.Close acForm, "signed_syops_results", acSaveNo
Else
DoCmd.Close acForm, "signed_syops", acSaveNo
DoCmd.Close acForm, "signed_syops_results", acSaveNo
End If
Else
DoCmd.Close acForm, "signed_syops", acSaveNo
End If
End Sub
I appologise if my code is really bad.