Cách xóa bảng trong Access 2010
RE: Xoá các table theo điều kiện trong Accessdannynguyen1980 > 10-11-11, 11:57 AM Bác cho hỏi luôn tôi có viết đoạn code sau để xóa bảng với điều khi bảng tồn tại trên database SQL Server 2000 (nối với Access 2003), khi gọi hàm DeleteTable không báo lỗi gì nhưng bảng cũng không xóa luôn. Code như sau: Option Compare Database Function DeleteTable(ByVal TableName As String) As Boolean 'References: Microsoft Access 11.0 Object Library, Microsoft DAO 3.6 Object Library On Error GoTo errhandler Dim Db As ADODB.Connection 'Create the Delte SQL Code from our Three Strings If ifTableExists(TableName) = True Then 'Print the SQL so we can paste into the query builder if there are errors 'delete table if found 'If no errors return true ExitHere: Set Db = Nothing errhandler: With Err Resume ExitHere End Function Function ifTableExists(TableName As String) As Boolean ' DAO Vars On Error GoTo NoTable 'If there is no table capture the error. Set Db = CurrentProject.Connection 'If Table is there open it Exit Function ifTableExists = False Mong bác chỉ giúp. |