オブジェクトの操作
クエリの実行
't_hogeテーブルを削除
DoCmd.RunSQL "DELETE * FROM t_hoge"
'追加・更新・削除 クエリ実行
DoCmd.OpenQuery "QD_hogehoge"
' テーブルを開く
DoCmd.OpenTable "テーブル名", acViewNormal, acEdit
'閉じる
DoCmd.Close acQuery, "Q_Name", acSaveYes
DoCmd.Close acTable, "テーブル名", acSaveYes
フォルダ内のテキストファイルをすべてインポートする
Dim MyPath As String
Dim MyFile As String
Dim MyName As String
'【データ保存先バスの設定】
MyPath = "D:\foldername\"
'【hogeで始まる拡張子txtのファイルのみ取得】
MyFile = MyPath & "hoge*.txt"
MyName = Dir(MyFile, vbNormal)
'フォルダ内のすべてのプラネットファイルを取り込む
Do While MyName <> ""
If MyName <> "." And MyName <> ".." Then
If GetAttr(MyPath & MyName) <> vbDirectory Then
'インポートの実行
DoCmd.TransferText acImportDelim, "インポート定義の名前", "テーブルの名前", MyPath & MyName, False, ""
End If
End If
MyName = Dir
Loop
Excelをインポート
DoCmd.TransferSpreadsheet acImport, , "商品管理テーブル", "K:\Access_Excel VBA Tips\Accessに追加用商品管理データ.xlsx", True
ミリ秒を取得
'ミリ秒を取得
Dim dblTimer As Double
dblTimer = CDbl(Timer)
getMSec = Fix((dblTimer - Fix(dblTimer)) * 100)
カレントディレクトリ
Dim current_path As String
current_path = Application.CurrentProject.Path