Full Version: Error Code
UtterAccess Discussion Forums > Microsoft® Access > Access Q and A
azhar2006
Hello all
What is error code

Private Sub Form_Load()
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

End Sub
Doug Steele
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
azhar2006
Hi DOUG
Thank you very much
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.