Wrox Programmer Forums
|
BOOK: Beginning Access VBA
This is the forum to discuss the Wrox book Beginning Access 2002 VBA by Robert Smith, Dave Sussman, Ian Blackburn, John Colby, Mark Horner, Martin Reid, Paul Turley, Helmut Watson; ISBN: 9780764544026
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning 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 May 21st, 2004, 07:12 AM
Registered User
 
Join Date: May 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 6 - problems with exercise

In trying to complete the second exercise of chapter 6, I am constantly receiving the following error message:

"Object variable or With block variable not set"

Can anyone explain the reason why I am receiving this message? According to the solutions section in the book, my code appears to be correct. I will, however, list my code below.

Thanks in advance.

Sub PermanentFormFonts(strFont As String)

    On Error GoTo PermanentFormFonts_Err

    Dim objAO As AccessObject 'an Access Object, ie. a form
    Dim objCP As Object 'Current Access project
    Dim ctlControl As Control 'control on a form

    'point to the current project
    Set objCP = Application.CurrentProject

    'loop through the forms in the project
    For Each objAO In objCP.AllForms
        'open the form in design view, and hidden
        DoCmd.OpenForm objAO.Name, acDesign ', , , , acHidden

        'loop through the controls setting the font
        For Each ctlControl In objAO.Controls
            ctlControl.FontName = strFont
        Next

        'close the form, saving the changes
        DoCmd.Close acForm, objAO.Name, acSaveYes
    Next

PermanentFormFonts_Exit:
    Exit Sub

PermanentFormFonts_Err:
    If Err.Number = 438 Then
        Resume Next
    Else
        MsgBox Err.Description
        Resume PermanentFormFonts_Exit
    End If

End Sub








Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 5 Exercise 2 diango BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 4 February 1st, 2011 03:24 PM
chapter 3 exercise 4 walkamongus BOOK: Beginning JavaScript 3rd Ed. ISBN: 978-0-470-05151-1 0 September 10th, 2007 09:34 PM
chapter 9 exercise michaelcode BOOK: Beginning ASP.NET 1.0 1 April 9th, 2006 03:56 PM
Chapter 5, Exercise 2, Class Problems nmstudent BOOK: Beginning Java 2 1 December 12th, 2003 07:08 PM
Chapter 8, Exercise 4 cjo BOOK: Beginning ASP.NET 1.0 0 November 3rd, 2003 02:26 PM





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