1

SQL クエリから取得したデータを操作してレポートに書き込みたいのですが、これはすべて MS Access の VBA で行います。

まず、このSQLクエリで必要なデータを取得する必要があります

SELECT test.number_id FROM test WHERE ((test.number_id)>30));

出力を変数に保存する必要があるとしましょう

Dim testVar As Int

そして私の計算をする

次に、結果をレポートに表示する必要があります。

それが可能かどうか、そしてこれを行う方法を知っている人はいますか???

4

1 に答える 1

1

SQL ステートメントをレコードセットに設定し、そこで結果を操作できます。

Dim myR2 As Recordset
Dim strSQL as String

strSQL = "SELECT test.number_id FROM test WHERE test.number_id>30"

Set myR = CurrentDb.OpenRecordset("strSQL", dbOpenDynaset)

'Manipulate myR info here'
myR.MoveFirst 'so you start from the first record'
myR.MoveNext 'to move to the next record; handy in a loop'
myR.FindFirst 'find a record in that recordset'
myR![FieldName] 'to call upon that record's field'
'Or use CREATE statement to create a new table and generate a report from it'

Set myR = Nothing
于 2013-07-24T17:37:29.213 に答える