2
我有一個Excel宏,可將數個Excel工作表中的數據複製到單個Access表中。除了訪問中的數據應該轉換爲mmmm yyyy
,而我將其複製到訪問權限時,它一直運行良好,它始終轉換爲dd/mm/yyyy
。VBA - 創建Access數據庫和更新字段屬性(日期/時間格式)的Excel宏
這些字段是「開始日期」和「結束日期」。
這裏是我的代碼的摘錄:
Dim Catalog As Object
Dim cn As ADODB.connection
Dim dbPath as String, scn as String
dbPath = CPTwb.Path & "\Flatfile.accdb"`
scn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & dbPath & ";"
Set Catalog = CreateObject("ADOX.Catalog")`
Catalog.Create scn
Set Catalog = Nothing
Set cn = New ADODB.connection
With cn
.Open scn
.Execute "CREATE TABLE Flatfile ([Tracker Product] text(255) WITH
Compression, " & "[Contract ID] text(255) WITH Compression, " & _
"[Client] text(255) WITH Compression, " & _
"[Start Date] datetime, " & "[End Date] datetime)"
End With
TheSQL = "INSERT INTO Flatfile ([Tracker Product], [ContractID], [Client],[Start Date], [End Date])"
TheSQL = TheSQL & "SELECT * FROM [Excel 12.0;HDR=YES;DATABASE=" & flatPath & "]." & "[" & Application.ActiveSheet.name & "$]"
cn.Execute TheSQL
cn.close
我理解的財產「DATATIME」總是得到值作爲系統日期,它是不可能通過DDL編輯。
有沒有辦法通過VBA申請屬性,如下面的截圖所示?
非常感謝,我會努力的! – rGabiru