进销存管理系统中的frm主页窗体的代码修改如下:
Function DoMenuCmd(MenuText As String, Optional strArgs As String = "")
On Error GoTo ErrorHandler
Dim strMenuID As String
'用来激活相应的窗口
strMenuID = Nz(DLookup("ID", "SysLocalNavigationMenus", "MenuText=" & SQLText(MenuText)))
With Me.Parent!ocxTreeMenu
Set .SelectedItem = .Nodes("K" & strMenuID)
Set .DropHighlight = .SelectedItem
RunMenuCommand Nz(.SelectedItem.Tag), Me.Parent!sfrChild, Me.Parent!lblNodePath
Forms!sysfrmmain!lblNodePath.Caption = Forms!sysfrmmain!ocxTreeMenu.SelectedItem.FullPath
End With
If strArgs <> "" Then
p_strType = strArgs
DoCmd.OpenForm "frm出入库管理_Edit"
' DoCmd.OpenForm "frm出入库管理_单据类型", , , , , , p_strtype
Else
p_strType = ""
End If
ExitHere:
Exit Function
ErrorHandler:
MsgBoxEx Err.Description, vbCritical
Resume ExitHere
End Function
在frm出入库管理_单据类型 窗体中的代码如下:
Private Sub btnCancel_Click()
DoCmd.Close acForm, Me.Name
End Sub
Private Sub btnOK_Click()
p_strType = Me.lst单据类型
DoCmd.OpenForm "frm出入库管理_Edit"
DoCmd.Close acForm, "frm出入库管理_单据类型"
End Sub
Private Sub Form_Load()
If p_strType <> "" Then
Me.lst单据类型.Value = p_strType
Me.lst单据类型.Locked = True
Else
Me.lst单据类型.Locked = False
End If
End Sub
Private Sub lst单据类型_DblClick(Cancel As Integer)
btnOK_Click '即运行确定按钮的单击事件
End Sub
在frm出入库管理 窗体中添加代码如下:
Private Sub Form_Unload(Cancel As Integer)
p_strType = ""
End Sub
该功能可在主页打开指定的单据类型,该功能可使只有在退出窗体frm出入库管理时,单据类型才会退出主页指定打开的单据类型