引用:
フィルターの結果を他のテーブルに保存する
引用:
T_グラフ用」テーブルの中身を削除して初期化する。
⇒フィルターの抽出結果を「T_グラフ用」テーブルに追加する。
そのフォームのレコードソースであるテーブル/クエリと
同一の構造を持つ(各フィールドの名前/データ型が
全て一致している)テーブルをあらかじめ定義しておく、
ということなのであれば一応可能です。
(フォームモジュール)
-----------------------------------------------------
Private Sub 抽出結果_cmd_Click()
If Me.FilterOn = False Then
MsgBox "フィルターを実行してください。", vbExclamation, "エラー"
Exit Sub
End If
If Me.Dirty Then
DoCmd.RunCommand acCmdSaveRecord
End If
Dim db As DAO.Database
Dim strSQL As String
Set db = CurrentDb
strSQL = "DELETE * FROM [T_グラフ用]"
db.Execute strSQL, dbFailOnError
Dim rsSource As DAO.Recordset
Dim rsDestination As DAO.Recordset
Set rsSource = Me.RecordsetClone
Set rsDestination = db.OpenRecordset("T_グラフ用", dbOpenDynaset)
Dim fldSource As DAO.Field
Dim fldDestination As DAO.Field
Do Until rsSource.EOF
rsDestination.AddNew
For Each fldSource In rsSource.Fields
Set fldDestination = rsDestination.Fields(fldSource.Name)
fldDestination.Value = fldSource.Value
Set fldDestination = Nothing
Next
rsDestination.Update
rsSource.MoveNext
Loop
Set rsSource = Nothing
Set rsDestination = Nothing
Set db = Nothing
DoCmd.OpenReport "R_抽出結果", acViewPreview, , Me.Filter
End Sub
-----------------------------------------------------