它是否降低了在MS Access中使用子表单的性能? [英] Does it degrade performance to use subforms in MS Access?

查看:147
本文介绍了它是否降低了在MS Access中使用子表单的性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑在父表单上使用一个选项卡控件,我希望有大约20个选项卡。我正在考虑使用一个或两个单独的子表单。每个子表格在编码逻辑中都会有不同的复杂性。通过采取这种方法,我会单独降低我的应用程序的性能?我目前在MS Access 2003中使用它。我预计在任何给定时间平均有15个用户在各种表单上。



想法?

解决方案

是的,每个子表单的性能会略微下降。一个或三个不是太糟糕,但二十个肯定会导致你的性能问题。



一旦你的子表单满足你的要求,将记录源保存为查询并为其指定名称或保存查询SQL字符串。然后,将查询名称或查询SQL字符串粘贴到选项卡控件更改事件中的VBA代码中。

  Private Sub TabCtl_Change()
出错时转到TabCtl_Change_Error

选择Case Me.TabCtl .Value
Case Me.pagPartsConsumed.PageIndex
如果Me.PartsConsumedsbf.Form.RecordSource<> Equipment - Parts Consumed sbfThen _
Me.PartsConsumedsbf.Form.RecordSource =Equipment - Parts Consumed sbf
....

现在为了确保我不会在启动时不小心留下一些子表单记录资源,以减慢应用程序的运行速度,我会检查代码运行的文件是否为MDB(而不是MDE),然后显示一条消息,告诉我必须删除记录源。

  If Not tt_IsThisAnMDE Then 
If Me.PartsConsumedsbf.Form.RecordSource<> 然后_
MsgBox设备的记录源 - 消耗的sbf不空
...
结束如果

公共函数tt_IsThisAnMDE()
On Error GoTo tagError

Dim dbs As Database
Set dbs = CurrentDb
Dim strMDE As String
On Error Resume Next
strMDE = dbs.Properties (MDE)
如果Err = 0并且strMDE =T则
'这是一个MDE数据库。
tt_IsThisAnMDE = True
Else
tt_IsThisAnMDE = False
End If

退出函数

tagError:
调用LogError(Application.CurrentObjectName,)
Exit Function

End Function



$ p
$ b

  Private Sub Form_Unload(取消为整数)b 

同样在unload事件中,我也清除了Recourd Source。

On Error GoTo Form_Unload_Error

Me.PartsConsumedsbf.Form.RecordSource =
....

顺便说一下,我几乎总是会将每个子表单放在一个单独的选项卡上。此外,很多标签条目在使用上显得笨拙。当我有类似的问题时,我的访问MVP的同事建议使用左侧的列表框来控制哪个子窗体是可见的。

每个组合框和列表框也会略微降低性能。所以,如果你有一个子表单,那么考虑类似的逻辑。


I am considering the use of a tab control on a parent form for which I would like to have around 20 tabs. Each tab I am considering the use of one or two separate sub forms. Each sub form will have varied complexity in coded logic. By taking this approach will I severally reduce the performance of my application? I am currently using this in MS Access 2003. I will expect an average of 15 users at any given time on the various forms.

Thoughts?

解决方案

Yes, performance will be degraded slightly for each subform. One or three isn't too bad but twenty is definitely going to cause you performance issues.

Once you have the subform working to your satisfaction either save the Record Source as a query and give it a name or save the query SQL string. Then either paste the query name or the query SQL string in the VBA code in the tab control change event.

Private Sub TabCtl_Change()
   On Error GoTo TabCtl_Change_Error

    Select Case Me.TabCtl.Value
    Case Me.pagPartsConsumed.PageIndex
        If Me.PartsConsumedsbf.Form.RecordSource <> "Equipment - Parts Consumed sbf" Then _
            Me.PartsConsumedsbf.Form.RecordSource = "Equipment - Parts Consumed sbf"
....

Now just to ensure that I don't accidentally leave some subform recordsources filled in slowing down the app on startup I check to see if the file the code is running is an MDB (instead of an MDE. The function is below) then display a message telling me I have to remove the recordsource.

   If Not tt_IsThisAnMDE Then
        If Me.PartsConsumedsbf.Form.RecordSource <> "" Then _
            MsgBox "Record source of Equipment - Parts Consumed sbf not empty"
        ...
   End If

Public Function tt_IsThisAnMDE()
On Error GoTo tagError

  Dim dbs As Database
  Set dbs = CurrentDb
  Dim strMDE As String
  On Error Resume Next
  strMDE = dbs.Properties("MDE")
  If Err = 0 And strMDE = "T" Then
    ' This is an MDE database.
    tt_IsThisAnMDE = True
  Else
    tt_IsThisAnMDE = False
  End If

    Exit Function

tagError:
    Call LogError(Application.CurrentObjectName, "")
    Exit Function

End Function

Also in the form unload event I clear the Recourd Source as well.

Private Sub Form_Unload(Cancel As Integer)

   On Error GoTo Form_Unload_Error

    Me.PartsConsumedsbf.Form.RecordSource = ""
    ....

BTW I almost always would put each subform on a seperate tab. Also that many tab entries gets visusally unwieldy. When I had a similar question my fellow Access MVPs suggested using a listbox along the left hand side to control which subform is viewable.

Also each combo box and list box will also slightly degrade the performance. So if you have those on a subform then consider similar logic.

这篇关于它是否降低了在MS Access中使用子表单的性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆