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 February 7th, 2004, 08:57 AM
Registered User
 
Join Date: Feb 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Access vba

Having trouble getting the "On Error GoTo..." construct to take
effect. I've tried everything but it never seems to take effect and
I'm unable to trap the error. Below is the procedure I'm testing. When
running this procedure, it never enters the FormFonts_Err code. VBA error message appears with the error number I'm trying to trap.

Sub FormFonts(strFont As String)

    On Error GoTo FormFonts_Err

    Dim frmCurrent As Form
    Dim ctlControl As Control

    For Each frmCurrent In Forms
        For Each ctlControl In frmCurrent.Controls
            ctlControl.FontName = strFont
        Next
    Next

FormFonts_Exit:
    Exit Sub

FormFonts_Err:
    If Err.Number = 438 Then
        Resume Next
    Else
        MsgBox Err.Description
        Resume FormFonts_Exit
    End If

End Sub
 
Old February 7th, 2004, 10:19 AM
Registered User
 
Join Date: Feb 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The following code gives an example of error trapping. In this case it relates to a simple command button that closes a form (DoCmd.Close).

Hope this helps.


Private Sub cmdExit_Click()
On Error GoTo Err_cmdExit_Click


    DoCmd.Close


Exit_cmdExit_Click:
    Exit Sub

Err_cmdExit_Click:
    MsgBox Err.Description
    Resume Exit_cmdExit_Click

End Sub

 
Old February 7th, 2004, 11:47 AM
Registered User
 
Join Date: Feb 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have tried this(took example right from Wrox book) but
for some reason the On Error GoTo is not taking effect
 
Old February 7th, 2004, 01:16 PM
Registered User
 
Join Date: Feb 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Have you compiled the code?

Perhaps if you post the code you have written, might be able see why its not working for you.



 
Old February 7th, 2004, 01:29 PM
sal sal is offline
Friend of Wrox
 
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Post your code. Are you trying to create an error to test it? or is your on error not doing something properly. Please be more clear.



Sal
 
Old February 7th, 2004, 01:37 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 120
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This may be the cause of the problem.

Open up the Visual Basic editor. Choose Options from the Tools menu. Click on the General tab. The Error Trapping option should be Break on Unhandled Errors.

If it's not, change it and see if that sorts it out.


Brian Skelton
Braxis Computer Services Ltd.
 
Old February 7th, 2004, 03:01 PM
Registered User
 
Join Date: Feb 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Braxis........That did it






Similar Threads
Thread Thread Starter Forum Replies Last Post
Code works in Excel VBA but not Access VBA fossx Access VBA 2 May 21st, 2007 08:00 AM
Access VBA Teqlump Access 2 September 10th, 2004 02:33 PM
please help! VBA in Access LittleCity Access VBA 3 December 3rd, 2003 08:53 PM
Access VBA help danielwajnberg Access VBA 3 September 1st, 2003 09:46 AM
Access XP VBA compatibility issues w/ Access 2000 bourgeois02 Access VBA 1 August 19th, 2003 04:14 PM





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