1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

AccessVBA TIPS 

Last updated at Posted at 2020-11-10

オブジェクトの操作

クエリの実行

        '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
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?