Solved

errors in Access

Posted on 2011-03-02
8
396 Views
Last Modified: 2012-05-11
I caught two errors
*Invalid use of Null
*No Current Record

with Err.Description (On Error GoTo Error Block)

how can i find which exact statements are throwing this error?

also the way the On Error Goto is positioned is like this: is it OK?
---------------------
Private Sub FuncName()
DIM..
DIM..
on error goto block_Name

regular statements

DataExp:
  On Error Resume Next
  SendKeys "{Down}"
  ds.Close
  Me.Air_Q_Subform.Requery
  Exit Sub
 
Block_Name:
  Response = MsgBox("The following error happens:" + Chr(13) + Chr(10) + Err.Description + Chr(13) + Chr(10) + "Go on?", vbQuestion + vbYesNo, "Input Data Error Message")
  If Response = 6 Then
    Resume Next
  Else
    Resume DataExp
  End If
Resume Next
End Sub
0
Comment
Question by:anushahanna
8 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 100 total points
Comment Utility
Set the error handling option to Break On All Errors  (Tools>options , General)
0
 
LVL 6

Author Comment

by:anushahanna
Comment Utility
PEter, this is access 2000(2)
options.jpg
0
 
LVL 77

Expert Comment

by:peter57r
Comment Utility
For code options you use the tools menu in VBA screen.
0
 
LVL 84

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 100 total points
Comment Utility
You can also set a Breakpoint in your Code, and "step through" the code line-by-line. To do that, highlight a line in your code (usually you'd start at the first line, unless you're sure the error is occuring after that) and press the F9 key. This will tell the VBA IDE to "break" when it hits that line.

Now run your code, and when Access tries to fire that line, you'll be thrown into the VBA IDE, and the line where you set the Breakpoint will be highlighted. Use the Debug menu to "step through" the code until you hit the line that is causing your error.

0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 11

Assisted Solution

by:LambertHeenan
LambertHeenan earned 100 total points
Comment Utility
If you go to this website
http://www.mztools.com/index.aspx

you can downlaod the free MZ tools add-in. With this add-in you can add line numbers to your codewith one button click (and remove them just as easily). You can also add an error handler to any sub or function with one button click. MZ Tools allows you to define a 'template' for what the error handler code should be. For eaple here is the one I use

   On Error GoTo {PROCEDURE_NAME}_Error
      {PROCEDURE_BODY}
{PROCEDURE_NAME}_Exit:
   On Error GoTo 0
   Exit {PROCEDURE_TYPE}

{PROCEDURE_NAME}_Error:
    ReportError Err.Number, Err.Description, "{PROCEDURE_NAME}", "{MODULE_TYPE} {MODULE_NAME}", "ERL=" & Erl
    'MsgBox "Error " & Err.Number & " : " & Err.Description & " at line " & Erl, vbOKOnly, "{PROCEDURE_NAME}"
    Resume {PROCEDURE_NAME}_Exit
    ' Next line only for debugging
    Resume

This templete uses my own standard error reporting routine called "ReportError". The Erl value iside the error hendler is the line number on which the error happened, hence the desirabiliy to add line numbers to the code.

The items in braces {} get automatically replaced by their correct values when you click the button to add an error handler.

0
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Access MVP)
DatabaseMX (Joe Anderson - Access MVP) earned 100 total points
Comment Utility
(no points)   MZTools ... MUST HAVE ... soooooo many cool features.  I use the line numbering all the time ... and as noted you can add the ERL function to your trapped errors message - GREAT for troubleshooting - gives you the exact line of code where there error occurs.

mx
0
 
LVL 10

Assisted Solution

by:LukeChung-FMS
LukeChung-FMS earned 100 total points
Comment Utility
Here's some code we recommend you invoke when your application starts to set the error handler to the right level: Microsoft Access VBA Debugging Tips and Techniques: Basic Error Handling http://www.fmsinc.com/free/newtips/vba/basicerrorhandling.asp

Trapping errors with line numbers: http://www.fmsinc.com/free/newtips/vba/ErrorHandling/LineNumber.html

VBA Debugging Techniques: http://www.fmsinc.com/tpapers/vbacode/Debug.asp

Hope this helps.
0
 
LVL 6

Author Comment

by:anushahanna
Comment Utility
Thanks all.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now