关闭Access中的模态窗体并访问模块代码

发布于 2024-08-16 23:48:24 字数 348 浏览 4 评论 0原文

我继承了一个Access数据库,用于在SQL中导入一些数据。 MDB 以模态模式打开一个表单:没有可见的 Access 菜单栏或按钮。我可以使用 Visual Studio“数据连接”工具查看表格内容,但看不到模块的代码。

我看过这个问题 这里,但那里的答案并不是我真正需要的。有没有办法强制表单关闭(并访问模块)或提取 VBA 代码?

[编辑] 我正在使用 Access 2007,不确定原始开发人员使用的是什么。

I've inherited a Access database that is used to import some data in SQL. The MDB opens with a form, in a modal mode: no Access menubar or buttons are visible. I can view the tables with content by using the Visual Studio 'Data Connection' tool, but I cannot see the module's code.

I've looked at this question here, but the answers there aren't really what I need. Is there a way to either force the form to close (and access the modules) or to extract the VBA code ?

[EDIT] I am using Access 2007, not sure what the original developer used.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

人事已非 2024-08-23 23:48:24

打开数据库时按住 Shift 键。这将阻止它加载正在运行的自动脚本,并允许您访问表、查询和 VBA 脚本。

Hold down the shift key when you open the database. This will prevent it from loading the automatic script it's running and allow you to gain access to the tables, queries, and VBA scripts.

暮年慕年 2024-08-23 23:48:24

这是对 Michael Todd 对 edosoft 评论的回复的相当长的补充或评论。

不要选择启用内容,而是检查启动选项((文件->选项->当前数据库->显示表单)或(工具->启动->显示表单))并删除记下表单的名称,并确保选中“允许完整菜单(同一页)”。您可能还想按 Alt+F11 显示代码,并检查启动代码,最后查看是否有 AutoRun 宏并重命名。

编辑评论

您不必打开 mdb 来更改启动表单,例如,可以使用您希望更改的 mdb 的全名和路径从另一个 mdb 运行此类代码。

Sub SetStartForm(DBFile As String)
Dim prp As Object
Dim db As Database

Const PROPERTY_NOT_FOUND As Integer = 3270

    Set db = OpenDatabase(DBFile)

    db.Properties("StartupForm") = "(none)" 

    If Err.Number > 0 Then
        If Err.Number = PROPERTY_NOT_FOUND Then
            '' Create the new property, but this is not relevant in this case
         End If
    End If

    db.Close
    Set db = Nothing
    Set prp = Nothing
End Sub

This is a rather long addendum to, or comment on, Michael Todd's reply in response to edosoft's comment.

Rather than choosing to enable the content, check the start-up options (either (file->options->current database->display form) or (tools->start up->display form)) and remove the name of the form, having taken a note, and ensure that Allow Full Menus (same page) is ticked. You may also like to press Alt+F11 to display code, and check that for start-up code, finally, see if there is an AutoRun macro and rename it.

EDIT re Comments

You do not have to open an mdb to change the start-up form, for example, code such as this could be run from another mdb using the full name and path of the mdb you wish to change.

Sub SetStartForm(DBFile As String)
Dim prp As Object
Dim db As Database

Const PROPERTY_NOT_FOUND As Integer = 3270

    Set db = OpenDatabase(DBFile)

    db.Properties("StartupForm") = "(none)" 

    If Err.Number > 0 Then
        If Err.Number = PROPERTY_NOT_FOUND Then
            '' Create the new property, but this is not relevant in this case
         End If
    End If

    db.Close
    Set db = Nothing
    Set prp = Nothing
End Sub
追星践月 2024-08-23 23:48:24

按钮关闭功能:

Private sub cmdClose_Click()
     CloseForm(YourFormName)
End sub

Public Sub CloseForm(ByVal strFormName As String)
    Dim iCounter As Integer
    For Each frm In Forms
        With frm
            If (.Name = strFormName) Then
                iCounter = iCounter + 1
            End If
        End With
    Next
    If (iCounter > 0) Then
        For i = 1 To iCounter
            DoCmd.Close acForm, strFormName, acSaveNo
        Next
    End If
End Sub

Button close with function:

Private sub cmdClose_Click()
     CloseForm(YourFormName)
End sub

Public Sub CloseForm(ByVal strFormName As String)
    Dim iCounter As Integer
    For Each frm In Forms
        With frm
            If (.Name = strFormName) Then
                iCounter = iCounter + 1
            End If
        End With
    Next
    If (iCounter > 0) Then
        For i = 1 To iCounter
            DoCmd.Close acForm, strFormName, acSaveNo
        Next
    End If
End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文