[AccessD] Flickering

Tony Septav TSeptav at Uniserve.com
Wed Nov 7 17:01:23 CST 2012


Hey Darryl
Will try it in the morning. Still concerned about what causes the problem.
As I mentioned I have never seen it before now.

Thanks kindly for the code.

Tony Septav
Nanaimo, BC
Canada

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Darryl Collins
Sent: November-07-12 4:10 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Flickering

Tony,

Try the following code - it was written for .mdb versions - I have never
used it in accdb.  It automatically fixes up the flicker if it is caused by
labels.

Cheers
Darryl




'==================== CODE STARTS HERE ===========================

Option Compare Database
Option Explicit

'The code below loops through all the controls on a form and locates the
labels
'that have a tab page as their parent.
'It changes the ControlType to text box, assigns the label's Caption to the
'text box's ControlSource, and sets the Enabled, Locked,
'and BackColor so the text box looks and behaves like a label.
'
'To use it to fix a form named "MyForm":
'
'Open a new module (Modules tab of Database window).
'Paste in the code.
'Open the Immediate Window (Ctrl+G), and enter:
'    Print ConvertLabelOnTabPage("frmPAI")
'The function lists to the Immediate Window the names of any labels
'that were converted.
'
'To fix all the forms in an Access 2003 database, enter:
'    Print FixAllForms()
'
'Warnings:
'
'This solution is not suitable if your application uses labels as
'quazi-buttons for the user to click. Since a disabled text box cannot
'be clicked, these "labels" would become inoperative.
'
'Backup your mdb before use. This code saves the changes without
confirmation.

'-------------------------------------------------------------------------

Function ConvertLabelOnTabPage(strFormName As String, _
        Optional bSaveAndClose As Boolean, Optional bHidden As Boolean)
    'Purpose:   Change unattached labels on pages of tab control into text
boxes.
    '           Avoids flicker bug under Windows XP themes.
    Dim frm As Form
    Dim ctl As Control
    Dim strName As String
    Dim strCaption As String
    Dim bytBackStyle As Byte
    Dim bChanged As Boolean
    Const strcQuote = """"
    
    'Open the form in design view
    DoCmd.OpenForm strFormName, acDesign, _
        windowmode:=IIf(bHidden, acHidden, acWindowNormal)
    Set frm = Forms(strFormName)
    
    'Find the labels whose parent is a tab page.
    For Each ctl In frm.Controls
        If ctl.ControlType = acLabel Then
            If ParentIsTabPage(ctl) Then
                bChanged = True
                strName = ctl.Name           'ctl reference will be lost.
                strCaption = ctl.Caption     'For ControlSource.
                bytBackStyle = ctl.BackStyle 'Access doesn't set this.
                'Convert it to a text box.
                ctl.ControlType = acTextBox
                'Set the text box properties.
                With frm.Controls(strName)  'ctl is now undefined.
                    .ControlSource = "=" & strcQuote & _
                        Replace(strCaption, strcQuote, strcQuote &
strcQuote) & strcQuote
                    .Enabled = False
                    .Locked = True
                    .BackStyle = bytBackStyle
                End With
            End If
        End If
    Next
    
    Set ctl = Nothing
    Set frm = Nothing
    If Not bChanged Then
        DoCmd.Close acForm, strFormName, acSaveNo
    ElseIf bSaveAndClose Then
        DoCmd.Close acForm, strFormName, acSaveYes
    End If
End Function

Private Function ParentIsTabPage(ctl As Control) As Boolean
    On Error Resume Next
    ParentIsTabPage = (ctl.Parent.ControlType = acPage)
End Function

Function FixAllForms()
    'Purpose:   Run ConvertLabelOnTabPage() for ALL forms in this database.
    'Warning:   Saves changes without confirmation.

    Dim accobj As AccessObject
    For Each accobj In CurrentProject.AllForms
        Call ConvertLabelOnTabPage(accobj.Name, True, True)
    Next
End Function

'===============  END OF CODE =============================================






-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Tony Septav
Sent: Thursday, 8 November 2012 6:16 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Flickering

Hey Rocky
As I mentioned to Charlotte, I may have to rebuild the form (not looking
forward to it) step by step to see what is causing this problem. I never
seen this before.

Thanks for your input.

Tony Septav
Nanaimo, BC
Canada

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin
Sent: November-07-12 1:08 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Flickering

I found this happening when the label was not associated with the control.
You can test it by rolling over a label and see if you get the flicker.  If
so, select the label, Cut it (ctrl-X), select the control, and paste
(ctrl-V)  The label will now be attached to the control.  Mouse over the
label and see if you still get flicker. 

No guarantees that's what problem you have, but that's how I solved one of
my flicker problems.

Rocky


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Tony Septav
Sent: Wednesday, November 07, 2012 10:45 AM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] Flickering

Hey All

I have a form which contains a tab with 2 pages. If I move the mouse cursor
back and forth over the tabs, the controls/buttons sometimes not always will
flicker/flash. Has anyone experienced this and possible found a way to stop
it?

 

Thanks 

Tony Septav

Nanaimo, BC 

Canada

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list