Subform flashing

D

Don Stone

Hi--

I am using Access 2007 to design a 2003 formatted database on a relatively
new computer using XP Professional. Everything seems to work just fine as
prescribed. However, I have a form containing about 18 tabbed subforms.
When this main form activates, all of the tabs flash for a few seconds.
This flashing also occurs each time I choose a different tab. Each tab
simply displays data from a table which is different than the table used the
main form.

Obviously, this is not satisfactory. Does anyone know of a method to stop
this screen flashing.

Thanks for the help!
 
D

Damon Heron

It is probably your labels on the forms and subforms.
I apologize in advance for whomever wrote the following solution, which I
used but neglected to write down who created it:

Damon

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":

1. Open a new module (Modules tab of Database window).
2. Paste in the code.
3. Open the Immediate Window (Ctrl+G), and enter:
? ConvertLabelOnTabPage("MyForm")

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:
? FixAllForms()
Warnings:
1. 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.
2. 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.
Debug.Print strFormName & "." & strName
'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
 
D

Don Stone

I need to modify one of my statements. The flashing occurs only when I open
the main form or change records on the main form. No flashing when
selecting a different tab.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top