Office中国论坛/Access中国论坛

标题: 源码:退出A.mdb打开另一个B.mdb数据库 [打印本页]

作者: 竹笛    时间: 2003-6-4 21:08
标题: 源码:退出A.mdb打开另一个B.mdb数据库
举一例子而已,希望大家可以举一反三。

1、您可以以此代码开发一个管理ACCESS文件的软件。
2、您也可以将不同的数据库放到一个窗体上进行管理。
……
窗体中代码:         
Private Sub 命令0_Click()
Dim stAppName As String
Dim strFileName As String
strFileName = ShortName(CurrentProject.Path + "\db2.mdb")
stAppName = "MSAccess.exe " & strFileName
Call Shell(stAppName, 1)
DoCmd.Quit acQuitSaveAll
End Sub

'模块中代码
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long

Function ShortName(ByVal LongName As String) As String
Dim sBuff As String
Dim x As Long
sBuff = Space$(512) ' make space
x = GetShortPathName(LongName, sBuff, Len(sBuff))
ShortName = Left$(sBuff, x)
End Function

[UseMoney=1][attach]651[/attach][/UseMoney]


[此贴子已经被作者于2003-6-4 13:18:10编辑过]






欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3