Private Sub Combo0_AfterUpdate()
Dim qry As DAO.QueryDef
Set qry = CurrentDb.QueryDefs("查询1")
If Me.Combo0 = "全部" Then
qry.SQL = "SELECT region FROM Data"
Else
qry.SQL = "SELECT region FROM Data where region='" & Me.Combo0 & "'"
End If
Me.child.SourceObject = "查询.查询1"
Me.Text3 = Me.child.Form.Recordset.RecordCount
End Sub
Private Sub Form_Load()
Dim rst As New ADODB.Recordset
Dim strSource As String
rst.Open "SELECT DISTINCT region FROM Data ORDER BY region", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
strSource = rst.GetString(, , , ";")
rst.Close
Me.Combo0.RowSourceType = "Value List"
Me.Combo0.RowSource = strSource & "全部;"
End Sub