Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / July 2005

Tip: Looking for answers? Try searching our database.

Programmatically Changing Form Appearance

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sprinks - 22 Jul 2005 14:35 GMT
We have an ever-growing multi-purpose application whose grey forms have
become a little tired-looking.  We'd like to make some simple changes to
color and positions of the title and eyebrow from their current locations,
etc.  The title and eyebrow are in a consistent place form to form.  Since
there about 100 forms, I'd like to do this programmatically.

I don't know how to:

- Cycle through the Forms collection
- Refer to a specific portion of the form, such as the Detail or Heading
sections

Can anybody point me in the right direction?

Thank you.
Sprinks
Marshall Barton - 22 Jul 2005 17:14 GMT
>We have an ever-growing multi-purpose application whose grey forms have
>become a little tired-looking.  We'd like to make some simple changes to
[quoted text clipped - 9 lines]
>
>Can anybody point me in the right direction?

I have no idea what you mean by "eyebrow".  If you mean the
title bar, then you can not change its color because that's
a Windows Display Property, not an Access setting.

You can loop through the open forms using:
    Dim frm As Form
    For Each frm in Forms
        frm.Caption = "some text here"
            . . .
    Next frm

OTOH, it almost sounds like you want to do this for all
forms as a design change instead of at runtime.  In this
case, you can use the Forms Container to locate the name of
each form Document.  In later versions of Access it's easier
to use the AllForms collection.

    Dim fobj As AccessObject
    For Each fobj In Application.AllForms
        DoCmd.OpenForm fobj.Name, acDesign
        With Forms(fobj.Name)
            .Caption = "some text here"
                . . .
        End With
        DoCmd.Close acForm, fobj.Name, acSaveYes
    Next fobj

Signature

Marsh
MVP [MS Access]

Sprinks - 22 Jul 2005 17:46 GMT
Marshall,

Thanks for your clear response; it's exactly what I needed.

BTW, the "eyebrow" reference was arcane jargon from my days of writing
product literature.  In this case, it's a textbox that displays the purpose
of the form, located directly underneath the title.

Thanks again.

> >We have an ever-growing multi-purpose application whose grey forms have
> >become a little tired-looking.  We'd like to make some simple changes to
[quoted text clipped - 36 lines]
>         DoCmd.Close acForm, fobj.Name, acSaveYes
>     Next fobj
Sprinks - 22 Jul 2005 18:15 GMT
Marshall,

I spoke too soon.  I placed the code in a Utility module, and placed a
command to call it.  An error was generated "Method or data member not
found", with the debugger highlighting "AllForms".  I'm using Access 2002
(10.2627.2625).  I figured it might be a missing reference.  Do you know
which one?  I also wondered if the form my button is on would generate an
error when the code attempted to close IT.

Also, I changed the code to the following, testing it on a single form.  It
generated the error "Operation is not supported for this type of object",
highlighting the For Each... line.  Do you know what this means?

Thank you.

Sprinks

Public Sub UpdateForms()
' Loop through Forms container
 Dim db As Database
 Dim fobj As AccessObject
 
 Set db = CurrentDb()
   For Each fobj In db.Containers!Forms
   'Application.AllForms
       DoCmd.OpenForm fobj.name, acDesign
       If fobj.name = "DuctTakeoffInit" Then
           With Forms(fobj.name)
               .FormHeader.BackColor = 255
               .Detail.BackColor = 16777215
               .FormFooter.BackColor = 16711680
           End With
       End If
       DoCmd.Close acForm, fobj.name, acSaveYes
   Next fobj
End Sub

> We have an ever-growing multi-purpose application whose grey forms have
> become a little tired-looking.  We'd like to make some simple changes to
[quoted text clipped - 12 lines]
> Thank you.
> Sprinks
Marshall Barton - 22 Jul 2005 19:20 GMT
You changed to using the Containers collection, but forgot
that an element in that collection is a Documents
collection.   This doesn't matter because the AllForms
collection works in A2002.

I had a mental lapse, the For Each statement should be:

For Each fobj In CurrentProject.AllForms
Signature

Marsh
MVP [MS Access]

>I spoke too soon.  I placed the code in a Utility module, and placed a
>command to call it.  An error was generated "Method or data member not
[quoted text clipped - 38 lines]
>> - Refer to a specific portion of the form, such as the Detail or Heading
>> sections
Sprinks - 22 Jul 2005 19:28 GMT
Marshall,

Awesome.  This is a BIG arrow in my quiver.

Thank you.

Sprinks

> You changed to using the Containers collection, but forgot
> that an element in that collection is a Documents
[quoted text clipped - 46 lines]
> >> - Refer to a specific portion of the form, such as the Detail or Heading
> >> sections
David C. Holley - 22 Jul 2005 20:19 GMT
If you're familar with DAO, you can use it to open the MSysObject table
and look for objects with the Type -32768. When you encounter one, you
can open it in design view and change the properties for the various
sections using...

Detail
PageHeader
PageFooter
FormHeader
FormFooter

as their names. These, of course, are the DEFAULT names for the
sections. As long as you haven't changed them, there shouldn't be a problem.

***WORD OF ADVICE*** I would create a backup copy of the database FIRST
before trying this and DEFINETLY for testing & development.

> We have an ever-growing multi-purpose application whose grey forms have
> become a little tired-looking.  We'd like to make some simple changes to
[quoted text clipped - 12 lines]
> Thank you.
> Sprinks
Sprinks - 22 Jul 2005 20:24 GMT
Thanks, David.

> If you're familar with DAO, you can use it to open the MSysObject table
> and look for objects with the Type -32768. When you encounter one, you
[quoted text clipped - 29 lines]
> > Thank you.
> > Sprinks
David C. Holley - 23 Jul 2005 01:19 GMT
You may want to do something where you document any form that you're not
able to modify programically and then examine each. Basically, if you
try to reference the sections by the default names and are unable to do
so, the section was probably renamed.

> Thanks, David.
>
[quoted text clipped - 31 lines]
>>>Thank you.
>>>Sprinks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.