Solved

errors in Access

Posted on 2011-03-02
8
402 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 77

Accepted Solution

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

Author Comment

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

Expert Comment

by:peter57r
ID: 35015925
For code options you use the tools menu in VBA screen.
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 85

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 100 total points
ID: 35015975
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
 
LVL 11

Assisted Solution

by:LambertHeenan
LambertHeenan earned 100 total points
ID: 35018318
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 - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 100 total points
ID: 35018914
(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:Luke Chung
Luke Chung earned 100 total points
ID: 35028191
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
ID: 35150525
Thanks all.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
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…

705 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