Solved

errors in Access

Posted on 2011-03-02
8
398 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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 - 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

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…
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…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

810 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