Pages

Showing posts with label Using Dmin in Access VBA. Show all posts
Showing posts with label Using Dmin in Access VBA. Show all posts

Tuesday, January 3, 2012

Using Dmin in Access VBA

If you want to use the Dmin in VBA.

Download Sample Database

Here is the code-

Sub use_dMIN()
Dim sumfield As String
Dim tblname As String
minsales = "sales"
tblname = "sales_detail"
MsgBox DMin(minsales, tblname, "[Rep Name] = 'a'"), vbOKOnly
' with query
Dim SQLresult As String
Dim rs As Recordset
SQLresult = "SELECT MIN([sales_detail].sales) AS Filtersales FROM [sales_detail] WHERE ([sales_detail].[rep name]='a')"
Set rs = CurrentDb.OpenRecordset(SQLresult)
MsgBox rs(0), vbInformation
End Sub