Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form opens to slow

Status
Not open for further replies.

brwnsuga21

Technical User
Aug 23, 2007
15
US
I have two forms linked to a Switchboard that opens really slowly. Is there something causing this? There is no data in the tables. The only thing I could think it is, is the VBA. Can that be the problem? Please help.
 
Difficult to say without knowing a bit more. Some things that could slow down a form opening are:

- A lot of controls on the form
- Multiple subforms
- Domain functions, eg DLookup()
- VBA code

You could try making a backup copy of your form, then gradually deleting code, dlookups, controls etc, until you find where the problem is being caused.


Max Hugen
Australia
 
Thanks. I will try that. Here is the code that i think may be causing an issue. Are there in know culprits in this list?

Private Sub CenterName_AfterUpdate()
Me!ManagerName.Requery
Me!ManagerName.SetFocus
End Sub

Private Sub DivisionName_AfterUpdate()
Me!OfficeName.Requery
Me!OfficeName.SetFocus
End Sub

Private Sub Form_Activate()

On Error GoTo Form_Activate_Error

DoCmd.ShowToolbar "Form View", acToolbarNo


Form_Activate_Exit:
Exit Sub

Form_Activate_Error:
MsgBox Err.Description
Resume Form_Activate_Exit

End Sub

Private Sub Form_Current()
Me.AU.RowSource = Me.AU.RowSource
End Sub


Private Sub Form_Deactivate()
On Error GoTo Form_Deactivate_Error

DoCmd.ShowToolbar "Form View", acToolbarWhereApprop


Form_Deactivate_Exit:
Exit Sub

Form_Deactivate_Error:
MsgBox Err.Description
Resume Form_Deactivate_Exit

End Sub

Private Sub OfficeName_AfterUpdate()
Me!AU.Requery
Me!AU.SetFocus
End Sub
Private Sub cmdAddNew_Click()
On Error GoTo Err_cmdAddNew_Click


DoCmd.GoToRecord , , acNewRec


Exit_cmdAddNew_Click:
Exit Sub
Err_cmdAddNew_Click:
MsgBox Err.Description
Resume Exit_cmdAddNew_Click

End Sub
Private Sub cmdSaveRecord_Click()
On Error GoTo Err_cmdSaveRecord_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_cmdSaveRecord_Click:
Exit Sub

Err_cmdSaveRecord_Click:
MsgBox Err.Description
Resume Exit_cmdSaveRecord_Click

End Sub
Private Sub cmdNextRecord_Click()
On Error GoTo Err_cmdNextRecord_Click


DoCmd.GoToRecord , , acNext

Exit_cmdNextRecord_Click:
Exit Sub

Err_cmdNextRecord_Click:
MsgBox Err.Description
Resume Exit_cmdNextRecord_Click

End Sub
Private Sub cmdPreviousRecord_Click()
On Error GoTo Err_cmdPreviousRecord_Click


DoCmd.GoToRecord , , acPrevious

Exit_cmdPreviousRecord_Click:
Exit Sub

Err_cmdPreviousRecord_Click:
MsgBox Err.Description
Resume Exit_cmdPreviousRecord_Click

End Sub
Private Sub cmdExitDatabase_Click()
On Error GoTo Err_cmdExitDatabase_Click


DoCmd.Quit

Exit_cmdExitDatabase_Click:
Exit Sub

Err_cmdExitDatabase_Click:
MsgBox Err.Description
Resume Exit_cmdExitDatabase_Click

End Sub
Private Sub cmdReturn_Click()
On Error GoTo Err_cmdReturn_Click


DoCmd.Close

Exit_cmdReturn_Click:
Exit Sub

Err_cmdReturn_Click:
MsgBox Err.Description
Resume Exit_cmdReturn_Click

End Sub


Private Sub cmdPrior_Click()
On Error GoTo Err_cmdPrior_Click


DoCmd.GoToRecord , , acPrevious

Exit_cmdPrior_Click:
Exit Sub

Err_cmdPrior_Click:
MsgBox Err.Description
Resume Exit_cmdPrior_Click

End Sub
 
Try removing any form events such as the Activate and Deactivate. Also, the Current event is setting a control's rowsource to what it already is (Me.AU.RowSource = Me.AU.RowSource)!

Apart from that, nothing else leaps out at me from the code. In fact, I think you could delete all the code in one go, and try the form again... but I don't think that's the problem.

So the next step would be to remove any domain functions, then start removing controls. OR, start with a new form, and copy a few controls at a time from your original form to the new form, each time checking the form's opening speed.

Max Hugen
Australia
 
Good tips. I'll try that. Will let you know how it goes.
 
thread705-1410038
Take a look at the two links discussed in the thread. They both have a ton of hints for speeding up databases and forms. Sometimes with forms it is not the data but like Max pointed out the design and complexity of the controls.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top