|
- Private Sub Command15_Click()
- On Error GoTo Err_Command15_Click
- Dim rs As DAO.Recordset
- Dim strTel As String
- Dim strWhere As String '定义条件字符串
- strWhere = "" '设定初始值是空字符串
- If Not IsNull(Me.姓名) Then
- strWhere = strWhere & "([姓名] like '*" & Me.姓名 & "*') AND "
- End If
- If Not IsNull(Me.性别) Then
- strWhere = strWhere & "([性别] like '*" & Me.性别 & "*') AND "
- End If
- If Not IsNull(Me.班级) Then
- strWhere = strWhere & "([学员班] like '*" & Me.班级 & "*') AND "
- End If
- If Not IsNull(Me.Combo41) Then
- strWhere = strWhere & "([学籍状态] like '*" & Me.Combo41 & "*') AND "
- End If
- If Len(strWhere) > 0 Then '如果有输入条件
- strWhere = Left(strWhere, Len(strWhere) - 5) '用LEFT函数截掉这5个字符。
- End If
- Me.查询学员_sub.Form.Filter = strWhere ' 子窗体应用窗体查询
- Me.查询学员_sub.Form.FilterOn = True
- Set rs = Me.查询学员_sub.Form.RecordsetClone
- With rs
- .MoveFirst
- Do While Not .EOF
- strTel = strTel & .Fields("联系电话") & ","
- .MoveNext
- Loop
- .Close
- End With
- Set rs = Nothing
- DoCmd.OpenForm "窗体1", acNormal, , , , , strTel
- Exit_Command15_Click:
- Exit Sub
- Err_Command15_Click:
- MsgBox Err.Description
- Resume Exit_Command15_Click
- End Sub
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|