Quantcast
Channel: OKWAVE 最新質問(Visual Basic/257)【本日】
Viewing all articles
Browse latest Browse all 6510

数値のMAXの値を取得したい ADO VBA

$
0
0
アクセスです。 ADOで該当のフィールドの数値のMAXの値を取得するにはどうすればいいですか? テーブルの番号フィールドには、 1 2 3 4 5 と入っているのですが、 この場合、一番大きい値は5なので MAX関数のようなもので5を返したいのですが ADOにそのようなプロパティはありますか? オブジェクトブラウザーでRecordsetを見てみましたが 見つけられませんでした。 Sub Sample() Dim cn As New ADODB.Connection Dim rs As New ADODB.Recordset Set cn = CurrentProject.Connection rs.CursorLocation = adUseClient rs.Open "SELECT * FROM T_test", cn, adOpenStatic, adLockPessimistic rs.Sort = "番号 DESC" Debug.Print rs("番号").Value rs.Close: Set rs = Nothing cn.Close: Set cn = Nothing End Sub これで同じような動きは出来ますが、 もっとシンプルにできませんか?

Viewing all articles
Browse latest Browse all 6510

Trending Articles