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 October 19th, 2003, 08:41 AM
Registered User
 
Join Date: Oct 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 6

I am trying to change the fonts of an opened form's controls and I always get the error:

Run-Time error 438
Object does not support this property of method!

OK as the book says this error occurs because some controls do not have any text like CHECK BOX but it should change the fonts of the rest of the Controls up to the point of the Check Box control.

Why doesn't it change the fonts?

This is the code:
Sub FormFonts1(strFont As String)
    Dim frmCurrent As Form
    Dim ctlControl As Control

For Each frmCurrent In Forms
    For Each ctlControl In frmCurrent.Controls
        ctlControl.FontName = strFont /* This is a big problem*/
    Next
Next

End Sub

the Second piece of code includes some Error Handling but it seems that the Error Handling code bit is the one one that always runs and the fonts type remains always the same:


Sub FormsFonts(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 ctlControl
Next frmCurrent

FormFonts_Exit:
Exit Sub


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

I try it in the Debug(Immediate) Window:
FormFonts1(Windings)
FormFonts(Windings)
but I cannot see any change

I also tries to do the exercises at the end with no success either!

For Each ctlControl In Forms(objAO.Name).Controls
    ctlControl.FontName = strFont
Next

I get Runtime error 91 on the first line For Each ctlControl In Forms(objAO.Name).Controls

 
Old January 22nd, 2004, 10:23 PM
Registered User
 
Join Date: Jan 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

My code for this sub runs, and the only diff is bolded

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

Not sure if that will help, or why but it works for me.

Chapter six exercise solutions

1. Go to design view of frmCompany. Grab the bar that separates the footer from the "page" and drag it down to allow another textbox. Click the textbox button on the toolset and drag out a new textbox. Doubleclick on the textbox itself. Type
"= RecordSet.AbsolutePosition" . Type a name in the label if you care. Close the form, save, and reopen. You should now see the absolute position of the record displayed. One Limitation I noticed that if you go to a new record, the absolute position displayed is the one from the last record (i.e. two record #10s).

2. Here's the sub

Public Sub ShowRelationships()

Dim db As Database
Dim objRel As Object

Set db = CurrentDb()

Debug.Print "Relationships:"; vbCrLf

For Each objRel In db.Relations

    Debug.Print objRel.Table; " is related to "; objRel.ForeignTable

Next

End Sub

Hope this helps. I would request folks start posting the answers they have found that comply with the requests of the exercises, and the reasoning behind them.

I understand the database was corrupted and thats why the link from the book is gone, but these people are the GURUs of IT! Certainly one of them could go through the book, solve all of the exercises and post the answers and the explanations in a weekend.

Help the NOObs. It why we bought your books...

Dead





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 2 - End of chapter exercises whizzkid1892 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 July 30th, 2008 12:02 PM
chapter 7 - chapter 11 pelopito BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 3 January 6th, 2008 11:40 AM
Generics chapter 12 difficult chapter i found ...? Larryz C# 2005 1 July 4th, 2007 09:40 PM





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