Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable error message caused by vbcode in report 1

Status
Not open for further replies.

frontside

Technical User
Sep 26, 2002
85
SE
Hey everyone

Is there anyone out there that knows how I could disable the error message that pops up when something goes wrong in vba code in a report.

I´m using vba in a report that checks a value in a field and writes a message in another field. Everything works fine until my query doesnt get any results. Then I get the message and It opens the vba coding form highlighting the wrong code.

Is there a way I could disable this function? or is there a way that I could check if I get any result before running my code?


//Micke Sweden
 
frontside
You could include code in your Error handling routine, to trap the specific error number you are receiving.

For example...
Code:
If Err.Number = "2501" Then
Exit Sub
Else

    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdSendMail_Click of VBA Document Form_frmSelect"
        
End If

Tom
 
To prevent the error, use code like:
Code:
If [HasData] Then
   'your code goes here
End If

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
that code worked perfect, Thanks dhookom!

Well worth a star
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top