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
|