Solved

errors in Access

Posted on 2011-03-02
8
397 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
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
 
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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 - Access MVP)
DatabaseMX (Joe Anderson - Access MVP) 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
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…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

911 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

21 Experts available now in Live!

Get 1:1 Help Now