'EXPORTS TABLE IN ACCESS DATABASE TO EXCEL 'REFERENCE TO DAO IS REQUIRED
Dim strExcelFile As String Dim strWorksheet As String Dim strDB As String Dim strTable As String Dim objDB As Database
'Change Based on your needs, or use 'as parameters to the sub strExcelFile = "C:\My Documents\MySpreadSheet.xls" strWorksheet = "WorkSheet1" strDB = "C:\My Documents\MyDatabase.mdb" strTable = "MyTable"
Set objDB = OpenDatabase(strDB)
'If excel file already exists, you can delete it here If Dir(strExcelFile) <> "" Then Kill strExcelFile
objDB.Execute _ "SELECT * INTO [Excel 8.0;DATABASE=" & strExcelFile & _ "].[" & strWorksheet & "] from " & "[" & strTable & "]" objDB.Close Set objDB = Nothing
初用ACCESS数据库,要实现一个关联查询,sql语句如下:select pid,product_Type.name as tid,name,img_url,context,remark from Product join product_Type on product.type_id = product_Type.type_id order by pid ......