所以我只是按照找到的Here步骤手动拆分数据库。由于某种原因,不会在一个表单上触发load事件,而在另一个表单上不会触发unload事件(但在每种情况下,相反的事件都会起作用)。第二种形式(卸载不工作)也拒绝进入设计模式,直到我手动关闭它然后将其打开到设计模式。我已经确认打开和关闭事件已正确链接到相应的VBA代码,所以我知道不是它。
任何有关解决此问题的帮助都将不胜感激。
编辑 -
以下是加载的代码:
Private Sub Form_Load()
Dim scr As ScriptControl
Dim SQL As String
CheckConnection
Set scr = New ScriptControl
SQL = "UPDATE [Part Number] SET [Part Number].[Select] = False WHERE ((([Part Number].[Select])=True));"
CurrentDb.Execute SQL
scr.Language = "VBScript"
scr.AddCode "Sub T :Dim ChangeReg: Set ChangeReg = CreateObject(""WScript.Shell""):ChangeReg.regwrite " & _
"""HKCU\Software\Microsoft\Office\12.0\Access\Security\VBAWarnings"", ""1"", ""REG_DWORD"" : " & _
"Set ChangeReg = CreateObject(""WScript.Shell""):ChangeReg.regwrite " & _
"""HKCU\Software\Microsoft\Office\12.0\Excel\Security\VBAWarnings"", ""1"", ""REG_DWORD"": end sub"
scr.Run "T"
Locked = False
CancelBupdate = False
LockOff
USRID = Environ("Username")
TTTCount = 0
Started = True
SourceSelect.Value = 1
DoCmd.SelectObject acTable, , True
DoCmd.RunCommand acCmdWindowHide
DoCmd.ShowToolbar "Ribbon", acToolbarNo
ChgFrmOpen = False
Me.LocationSelect.Visible = False
Me.ClrSupLoc.Visible = False
Me.Label20.Visible = False
PSOn = True
Me.RepSelect.Value = ""
Me.SupplierSelect.Value = ""
Me.SupNumSelect.Value = ""
Me.LocationSelect.Value = ""
Me.Base5Select.Value = ""
Me.FullNbrSelect.Value = ""
Me.Label104.Caption = "Last Updated On: " & DLookup("[Last Updated]", "[Last Updated]")
ChangeCount = 0
CT = ""
CPP = ""
PGNP = ""
UpdateSub '****
InfoGet
RunFilter
Cascade
Me.Requery
Select Case USRID
Case "vn034153"
UsrInfoSt = "Logged in as User"
Case "vn043156"
UsrInfoSt = "Logged in as User"
Blah
Case "vn034157"
UsrInfoSt = "Logged in as Admin"
Me.UpdateButton.Visible = True
Case "vn034160"
UsrInfoSt = "Logged in as User"
Case "vn028040"
UsrInfoSt = "Logged in as User"
Case "vn028033"
UsrInfoSt = "Logged in as Admin"
Me.UpdateButton.Visible = True
Case "vn034931"
UsrInfoSt = "Logged in as User"
Case Else
UsrInfoSt = "Logged in as User"
End Select
Me.UsrInfo.Caption = UsrInfoSt
Application.SetOption "Confirm Action Queries", 0
Application.SetOption "Confirm Document Deletions", 0
Application.SetOption "Confirm Record Changes", 0
DoCmd.SetWarnings False
Application.SetOption "Auto compact", True
End Sub
以下是卸载的代码(使用cmd按钮且不运行子程序):
Private Sub OpenDatabase_Click()
DoCmd.OpenForm "2BHPartsDatabaseX"
DoCmd.Close acForm, Me.Name
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim TDF As TableDef
Dim QDF As QueryDef
Dim DBS As Database
Set DBS = CurrentDb()
Me.ReportForm.SourceObject = ""
For Each QDF In DBS.QueryDefs
If QDF.Name = "TempQRYX" Or QDF.Name = "DistinctPGNQry" Then
DBS.QueryDefs.Delete QDF.Name
End If
Next
For Each TDF In DBS.TableDefs
If TDF.Name = "ProjectTable" Then
DBS.TableDefs.Delete TDF.Name
Exit For
End If
Next
Application.SetOption "Confirm Action Queries", 1
Application.SetOption "Confirm Document Deletions", 1
Application.SetOption "Confirm Record Changes", 1
DoCmd.SetWarnings True
End Sub
答案 0 :(得分:1)
我会评论(rem)出Form_Load事件中的所有代码,并在其上放置一个断点 子程序,然后打开表单以查看事件是否触发。看到它之后, 我会开始" un-rem"每行直到代码行影响load事件 找到了。
我会对"卸载"问题。