What do you mean?
If you're getting an error message, what's the exact message?
You might try putting in error handling:
CODE
Private Sub Form_Load()
On Error GoTo ErrorHandler
Dim intStore As Integer
intStore = DCount("[naibr]", "[ans]", "[b] <=10 AND [check] =-1 ")
If intStore = 0 Then
Exit Sub
Else
If MsgBox(" " & intStore & "" & "" & vbCrLf & vbCrLf & _
" " & " " & " ", vbYesNo Or vbExclamation Or vbDefaultButton1, " ") = vbYes Then
DoCmd.Close
DoCmd.OpenForm "Q"
End If
End If
Cleanup:
Exit Sub
ErrorHandler:
MsgBox Err.Number & ": " & Err.Description
Resume Cleanup
End Sub
Possible errors in your code include (but aren't necessarily limited to):
- You don't have a table named ans in your database
- Table ans in your database doesn't have one (or more) of the fields naibr, b or check in it
- DCount is finding more than 32,767 rows (the maximum value an Integer can hold)
- You don't have a form named Q in your database