Solved

errors in Access

Posted on 2011-03-02
8
400 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
Independent Software Vendors: 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!

 
LVL 84

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

726 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