Absolute_Beginner
Registered User.
- Local time
- Today, 21:59
- Joined
- Aug 3, 2011
- Messages
- 10
Hello everybody,
I have a search form, which works with the following code (wasn't written by me). If the search was successful, a new form pops up displaying the matching data.
I would now like a message box to pop up, displaying the number of results found.
How can I accomplish that? Thank you for your help!
I have a search form, which works with the following code (wasn't written by me). If the search was successful, a new form pops up displaying the matching data.
Code:
Private Sub Befehl33_Click()
'Suche starten
Dim rst As DAO.Recordset
Dim ctl As Control
Dim strCriteria As String
Dim strCriteria2 As String
Dim strCriteria3 As String
Dim strSQL As String
Dim strINList_Sitzung As String
Dim strINList_themen As String
strCriteria = "1 = 1"
For Each ctl In Me.Controls
If ctl.Tag <> "" Then
If Nz(ctl.Value, "") <> "" Then
Select Case ctl.Tag
Case "Aufgabe", "Beauftragter"
strCriteria = strCriteria & " AND [" & ctl.Tag & "] Like '*" & ctl.Value & "*'"
Case "Datum_1"
If IsDate(ctl.Value) Then strCriteria = strCriteria & " AND [Datum] >= " & Format(ctl.Value, "\#yyyy\-mm\-dd\#")
Case "Datum_2"
If IsDate(ctl.Value) Then strCriteria = strCriteria & " AND [Datum] <= " & Format(ctl.Value, "\#yyyy\-mm\-dd\#")
Case "Erledigt"
If ctl.Value = 1 Then
strCriteria = strCriteria & " AND [" & ctl.Tag & "] = True"
ElseIf ctl.Value = 2 Then
strCriteria = strCriteria & " AND [" & ctl.Tag & "] = False"
End If
Case Else
End Select
End If
End If
Next ctl
strCriteria2 = strCriteria
strCriteria = "WHERE " & strCriteria
strSQL = "SELECT DISTINCT tblThemen.themen_id, tblThemen.sitzung_id_f AS sitzung_id " & _
"FROM tblThemen INNER JOIN tblAufgabe ON tblThemen.themen_id = tblAufgabe.themen_ID_f " & _
strCriteria & ";"
Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
With rst
Do Until .EOF
If Len(strINList_Sitzung) > 0 Then strINList_Sitzung = strINList_Sitzung & ","
strINList_Sitzung = strINList_Sitzung & !sitzung_id
If Len(strINList_themen) > 0 Then strINList_themen = strINList_themen & ","
strINList_themen = strINList_themen & !themen_id
.MoveNext
Loop
.Close
End With
Set rst = Nothing
If Len(strINList_Sitzung) > 0 Then
strCriteria = "sitzung_id IN ( " & strINList_Sitzung & " )"
DoCmd.OpenForm "frmSitzung3", , , strCriteria
DoEvents
Forms("frmSitzung3").ufoAufgaben2.Form.Filter = strCriteria2
strCriteria3 = "themen_id IN ( " & strINList_themen & " )"
Forms("frmSitzung3").ufoThemen2.Form.Filter = strCriteria3
Forms!frmSitzung3.AllowEdits = False
Forms!frmSitzung3!ufoThemen2.Form.AllowEdits = False
Forms!frmSitzung3!ufoAufgaben2.Form.AllowEdits = False
Else
MsgBox "No records were found matching the specified criteria.", vbInformation, "Mo match"
End If
I would now like a message box to pop up, displaying the number of results found.
How can I accomplish that? Thank you for your help!