Name 函数的问题
程序代码:
Sub ClearDatabase(DBname As String) '清空指定的Access mdb文件中的所有表格 Set cn = New ADODB.Connection cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Local DB\" & DBname & ".mdb;Persist Security Info=False;Jet OLEDB:Database Password=" cn.Open ComboSht.Clear Set myrec = cn.OpenSchema(adSchemaTables, Array(Empty, Empty, Empty, "Table")) Do While Not myrec.EOF ComboSht.AddItem myrec!Table_name myrec.MoveNext Loop Set myrec = New ADODB.Recordset For i = 0 To ComboSht.ListCount - 1 sqltxt = "delete from [" & Trim(ComboSht.List(i)) & "]" myrec.Open sqltxt, cn, 1, 2 Next i Name App.Path & "\Local DB\" & DBname & ".mdb" As App.Path & "\Local DB\" & DBname & "-1.mdb" Dim dbE As New DAO.DBEngine App.Path & "\Local DB\" & DBname & "-1.mdb", App.Path & "\Local DB\" & DBname & ".mdb" Kill App.Path & "\Local DB\" & DBname & "-1.mdb" End Sub
上面加红的这段。Name本来是一个函数,但是不知道为什么运行的时候变成了一个字符变量,内容是窗体的名称。。。 我也没有定义这个变量。 不知何解
如果最后这几行放在外面使用又是可以的,比如说
ClearDatabase DBname
Name App.Path & "\Local DB\" & DBname & ".mdb" As App.Path & "\Local DB\" & DBname & "-1.mdb"
Dim dbE As New DAO.DBEngine
App.Path & "\Local DB\" & DBname & "-1.mdb", App.Path & "\Local DB\" & DBname & ".mdb"
Kill App.Path & "\Local DB\" & DBname & "-1.mdb"