|
Question : To many controls on a form- Reports SLOW!!
|
|
When I run the the "Perfomance" tab on the tools menu- It always says to use fewer controls on this form- Also Reports take FOREVER TO RUN ON IT!!
What can I do to speed up this process and is there something wrong with this form??
Help me please! Thanks!
Option Compare Database Option Explicit
Private Sub Form_Current() Me.ActiveXCtl34 = Date End Sub
Private Sub Form_Open(Cancel As Integer) DoCmd.Maximize End Sub
Private Sub Form_Unload(Cancel As Integer) Me!cmbSelectManager = "" Me!cmbEmployeeName = "" Me!cmbEmployeeName = "" Me!cmbseletgroup = "" Me!cmbseletgroup = "" Me!TxBeginDate = "" Me!TxEndDate = "" Me.OptAllRecords.Parent.SetFocus Me.OptAllRecords.Parent.Value = Me.OptAllRecords.OptionValue
End Sub
Private Sub Option21_GotFocus() Me!cmbSelectManager.Enabled = True Me!cmbEmployeeName.Enabled = False Me!cmbEmployeeName = Null Me!cmbseletgroup = Null Me!cmbseletgroup.Enabled = False Me!Command14.Visible = True Me!Command15.Visible = False Me.cmex1.Visible = True Me.cmex2.Visible = False Me.cmgt1.Visible = True Me.cmgt2.Visible = False End Sub
Private Sub Option3_GotFocus() Me!cmbEmployeeName.Enabled = True Me!cmbSelectManager.Enabled = False Me!cmbSelectManager = Null Me!cmbseletgroup = Null Me!cmbseletgroup.Enabled = False Me!Command14.Visible = True Me!Command15.Visible = False Me.cmex1.Visible = True Me.cmex2.Visible = False Me.cmgt1.Visible = True Me.cmgt2.Visible = False End Sub
Private Sub optselectall_GotFocus() Me!cmbEmployeeName.Enabled = False Me!cmbEmployeeName = Null Me!cmbSelectManager.Enabled = False Me!cmbSelectManager = Null Me!cmbseletgroup.Enabled = False Me!cmbseletgroup = Null Me!Command14.Visible = False Me!Command15.Visible = True Me.cmex1.Visible = False Me.cmex2.Visible = True Me.cmgt1.Visible = False Me.cmgt2.Visible = True End Sub
Private Sub optselectgroup_GotFocus() Me!cmbEmployeeName.Enabled = False Me!cmbEmployeeName = Null Me!cmbSelectManager.Enabled = False Me!cmbSelectManager = Null Me!cmbseletgroup.Enabled = True Me!Command14.Visible = True Me!Command15.Visible = False Me.cmex1.Visible = True Me.cmex2.Visible = False Me.cmgt1.Visible = True Me.cmgt2.Visible = False
End Sub
Private Sub OptAllRecords_GotFocus() Me!TxBeginDate = Null Me!TxEndDate = Null Me!TxBeginDate.Enabled = False Me!TxEndDate.Enabled = False End Sub
Private Sub OptSelectDates_GotFocus() Me!TxBeginDate.Enabled = True Me!TxEndDate.Enabled = True End Sub
Private Sub Command14_Click() On Error GoTo Err_Command14_Click
Dim stDocName As String Dim stCriteria As String
If cmbEmployeeName.Enabled = True Then stCriteria = "[Employee_Name]='" & Me.cmbEmployeeName & "'" ElseIf Me.cmbseletgroup.Enabled = True Then stCriteria = "[Group]='" & Me.cmbseletgroup & "'" Else stCriteria = "[Manager]='" & Me.cmbSelectManager & "'" End If stDocName = "Rpt_Project" DoCmd.OpenReport stDocName, acViewPreview, , stCriteria
Exit_Command14_Click: Exit Sub
Err_Command14_Click: MsgBox Err.Description
End Sub
Private Sub Command15_Click() On Error GoTo Err_Command15_Click
Dim stDocName As String
stDocName = "Rpt_Project" DoCmd.OpenReport stDocName, acPreview
Exit_Command15_Click: Exit Sub
Err_Command15_Click: MsgBox Err.Description Resume Exit_Command15_Click End Sub
Private Sub Cmex1_Click() On Error GoTo Err_Cmex1_Click
Dim stDocName As String Dim stCriteria As String If cmbEmployeeName.Enabled = True Then stCriteria = "[Employee_Name]='" & Me.cmbEmployeeName & "'" ElseIf Me.cmbseletgroup.Enabled = True Then stCriteria = "[Group]='" & Me.cmbseletgroup & "'" Else stCriteria = "[Manager]='" & Me.cmbSelectManager & "'" End If
stDocName = "RptExpense" DoCmd.OpenReport stDocName, acViewPreview, , stCriteria
Exit_Cmex1_Click: Exit Sub
Err_Cmex1_Click: MsgBox Err.Description
End Sub
Private Sub Cmex2_Click() On Error GoTo Err_Cmex2_Click
Dim stDocName As String
stDocName = "RptExpense" DoCmd.OpenReport stDocName, acPreview
Exit_Cmex2_Click: Exit Sub
Err_Cmex2_Click: MsgBox Err.Description Resume Exit_Cmex2_Click End Sub
Private Sub Cmgt1_Click() On Error GoTo Err_Cmgt1_Click Dim strMsg As String, strTitle As String Dim intStyle As Integer Dim strDocName As String, strLinkCriteria As String Dim stDocName As String Dim stCriteria As String 'If Date Control is blank, display a message If IsNull(Me![TxBeginDate] Or Me![TxEndDate]) Then strMsg = "You must select dates to view this report" intStyle = vbOKOnly strTitle = "Select Begin Date" Me.OptSelectDates.Parent.SetFocus Me.OptSelectDates.Parent.Value = Me.OptSelectDates.OptionValue MsgBox strMsg, intStyle, strTitle Exit Sub
Else If cmbEmployeeName.Enabled = True Then stCriteria = "[Employee_Name]='" & Me.cmbEmployeeName & "'" Else If Me.cmbseletgroup.Enabled = True Then stCriteria = "[Group]='" & Me.cmbseletgroup & "'" Else If Me.cmbSelectManager.Enabled = True Then stCriteria = "[Manager]='" & Me.cmbSelectManager & "'" End If End If End If
stDocName = "RptGrouptime" DoCmd.OpenReport stDocName, acViewPreview, , stCriteria
Exit_Cmgt1_Click: Exit Sub Err_Cmgt1_Click: MsgBox Err.Description Resume Exit_Cmgt1_Click End If End Sub
Private Sub Cmgt2_Click() On Error GoTo Err_Cmgt2_Click
Dim strMsg As String, strTitle As String Dim intStyle As Integer Dim strDocName As String, strLinkCriteria As String Dim stDocName As String Dim stCriteria As String 'If Date Control is blank, display a message If IsNull(Me![TxBeginDate] Or Me![TxEndDate]) Then strMsg = "You must select dates to view this report" intStyle = vbOKOnly strTitle = "Select Begin Date" Me.OptSelectDates.Parent.SetFocus Me.OptSelectDates.Parent.Value = Me.OptSelectDates.OptionValue MsgBox strMsg, intStyle, strTitle Exit Sub Else stDocName = "RptGrouptime" DoCmd.OpenReport stDocName, acPreview
Exit_Cmgt2_Click: Exit Sub
Err_Cmgt2_Click: MsgBox Err.Description Resume Exit_Cmgt2_Click End If End Sub
|
|
Answer : To many controls on a form- Reports SLOW!!
|
|
The Analyzer means to reduce the number of controls (textboxes, combos, etc) on your form - and especially bound combos and listboxes. Most of the code you've included is Click event code, which wouldn't have anything to do with performance until the user clicks your command button. How many controls do you have on the form? Are you using subforms (or sub-subforms)? I have one bound form with appx 50 controls (2 subforms, about 15 bound combos, the rest textboxes) but the app performs very nicely, even across a network.
Also look into indexing your tables, if you haven't already done so. Poorly indexed tables can be major performance hogs.
Poor database strucutre can cause problems, as can improperly constructed queries.
IOW, there are MANY things that can affect performance ...
|
|
|
|