Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 21st, 2006, 03:15 PM
Authorized User
 
Join Date: Aug 2006
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help with Error Checking

Hello,
  I've got a bit of code which is function, but pretty horrific when it comes to handling errors because I am not very familiar with error handling. So, what I would really like is two things.

1) I'd like help with adding some error checking to my code.
2) I'd like some references for error handling/checking so I can start learning more about it.

Code:
Code:
Private Sub ISBN_Exit(Cancel As Integer)
Set db = CurrentDb()
Dim strISBN, sSQL As String
strISBN = Me.ISBN
sSQL = "SELECT * FROM tbl_Books WHERE [ISBN] = '" & strISBN & "'"

Set rst = db.OpenRecordset(sSQL, dbOpenDynaset)

'all information in here where "Order#" is a column in your table

[Book_Title] = rst("Book_Title")
[Publisher] = rst("Publisher")
[Copyright] = rst("Copyright")
[Edition] = rst("Edition")
[Author] = rst("Author")
[Book_Type] = rst("Book_Type")
[Trial_Software] = rst("Trial_Software")
[Comments] = rst("Comments")

rst.Close

End Sub
Thanks in advance.

Best Regards,
Arholly

 
Old December 22nd, 2006, 08:08 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Normally, to do error handling, you turn off error handling by the app using this line:

On Error Resume Next

Then after each step where you want to check for an error, take the value like this:

If Err <> 0 Then
   'Error Handling code
    Err.Clear
End If

I learned error handling from VBScript, as you can tell.

HTH

mmcdonal
 
Old December 22nd, 2006, 03:40 PM
Authorized User
 
Join Date: Aug 2006
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking for duplicates toedipper2 SQL Server 2000 3 June 7th, 2006 03:50 PM
"Pause" Checking ... tonyrosen Excel VBA 2 November 23rd, 2005 11:02 AM
Error checking for table fields null value constra method Access VBA 1 September 26th, 2005 09:00 PM
Checking for Null ~Bean~ BOOK: Beginning ASP 3.0 2 June 27th, 2005 07:09 AM
checking for duplicates jammykam Access 3 October 2nd, 2003 08:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.