在启动窗体的Open事件或Load事件中调用以下代码:
Private Sub Form_Open(Cancel As Integer)Dim rst As Object 'ADODB.RecordsetDim intCounter As Integer
Set rst = CurrentProject.Connection.OpenSchema(adSchemaProviderSpecific, , "{947bb102-5d43-11d1-bdbf-00c04fb92675}")Do Until rst.EOFintCounter = intCounter + 1rst.MoveNextLoopSet rst = NothingIf intCounter > 1 ThenMsgBox "不允许重复运行程序!", vbExclamation Cancel = TrueQuitEnd If End Sub
阅读原文:
防止同一个客户端文件被重复打开的又一种方法【Access软件网】 http://www.accessoft.com/article-show.asp?id=4775