G
Guest
I designed a database application with approximately 30 forms in it. Now, the
powers that be decided that they want the appearance of the forms to be
different, but the functionality is ok. Each form has a header with a label
lblFormTitle and a footer with an image control imgCompanyLogo. I am trying
to write a module that has a SetFormAppearance() function, that each form can
call on load to set properties such as imgCompanyLogo.Picture,
lblFormTitle.Font, etc. I would also like to be able to set the Header and
Footer Section heights as well. The code I have below is incomplete (in that
there are other properties I would like to set, but I think I have a
representative few selected so far), but it still crashes out. I call it as
SetFormAppearance(Me) in the load event code for each form (well, a single
form at this point, but once it works it will be in all forms). The error it
generates is "438 - Object doesn't support this property or method". While I
am not certain about the syntax for header height, the code to set the
picture sources works elsewhere in the database as "Me.Form.Picture = ..."
Any thoughts? Thanks,
Matt
Public Sub SetFormAppearance(frm As Form)
' Set form background, header and footer control properties
On Error GoTo SetFormAppearance_Error
' Constant for error handling
Const conImageFilesNotFound = 2220
' Set form background
frm.Form.Picture = Nz(DLookup("[PathFormBackGround]", "[tblPaths]"),
"????")
' Set header properties
frm.FormHeader.Height = 0.4271 'InchesToTwips(0.4271)
frm.lblFormTitle.Left = 0.5 'InchesToTwips(0.5)
' Set footer properties
frm.imgCompanyLogo.Picture = Nz(DLookup("[PathBCTLogo]", "[tblPaths]"),
"????")
SetFormAppearance_Exit:
Exit Sub
SetFormAppearance_Error:
Select Case Err
Case conImageFilesNotFound
Resume Next
Case Else
MsgBox Err.Number & " - " & Err.Description
'CloseCurrentDatabase
'Resume SetFormAppearance_Exit
Resume Next
End Select
End Sub
Public Function InchesToTwips(dblInches As Double) As Integer
InchesToTwips = Int(dblInches * 1440) '(1440 twips per in)
End Function
powers that be decided that they want the appearance of the forms to be
different, but the functionality is ok. Each form has a header with a label
lblFormTitle and a footer with an image control imgCompanyLogo. I am trying
to write a module that has a SetFormAppearance() function, that each form can
call on load to set properties such as imgCompanyLogo.Picture,
lblFormTitle.Font, etc. I would also like to be able to set the Header and
Footer Section heights as well. The code I have below is incomplete (in that
there are other properties I would like to set, but I think I have a
representative few selected so far), but it still crashes out. I call it as
SetFormAppearance(Me) in the load event code for each form (well, a single
form at this point, but once it works it will be in all forms). The error it
generates is "438 - Object doesn't support this property or method". While I
am not certain about the syntax for header height, the code to set the
picture sources works elsewhere in the database as "Me.Form.Picture = ..."
Any thoughts? Thanks,
Matt
Public Sub SetFormAppearance(frm As Form)
' Set form background, header and footer control properties
On Error GoTo SetFormAppearance_Error
' Constant for error handling
Const conImageFilesNotFound = 2220
' Set form background
frm.Form.Picture = Nz(DLookup("[PathFormBackGround]", "[tblPaths]"),
"????")
' Set header properties
frm.FormHeader.Height = 0.4271 'InchesToTwips(0.4271)
frm.lblFormTitle.Left = 0.5 'InchesToTwips(0.5)
' Set footer properties
frm.imgCompanyLogo.Picture = Nz(DLookup("[PathBCTLogo]", "[tblPaths]"),
"????")
SetFormAppearance_Exit:
Exit Sub
SetFormAppearance_Error:
Select Case Err
Case conImageFilesNotFound
Resume Next
Case Else
MsgBox Err.Number & " - " & Err.Description
'CloseCurrentDatabase
'Resume SetFormAppearance_Exit
Resume Next
End Select
End Sub
Public Function InchesToTwips(dblInches As Double) As Integer
InchesToTwips = Int(dblInches * 1440) '(1440 twips per in)
End Function