I have this search form finaly working that it shows the search result in a subform.
In brief the idea of how it works.
In a form I have 5 combo's for search criteria which are combined to a search string.
When hit the search button the code below uses this string as the WHERE function.
All goes as planned, however when leaving the search form, the search criteria, also when all empty, is put on the first record of the table attached to the searchform!
What can be the problem here?
Here is the code:
Private Sub Zoekknop_Click()
Dim strSQL As String
Dim strWhere As String
strWhere = Zoeken_op()
strSQL = "SELECT DISTINCTROW Organisaties.Plaats, " & _
"Organisaties.Doelgroep, Organisaties.Categorie, " & _
"Organisaties.Subcategorie, Organisaties.Trefwoord, " & _
"Organisaties.Organisatienaam, Organisaties.OrganisatieID as Recordnr " & _
"FROM Organisaties " & _
"WHERE " & strWhere & ";"
Me!Zoekresultaat.Form.RecordSource = strSQL
Me!Zoekresultaat.Form.Requery
If Me.Zoekresultaat.Form.RecordsetClone.RecordCount = 0 Then
DoCmd.Hourglass False
MsgBox "Er zijn geen aktiviteiten die voldoen aan de zoek criteria.", vbInformation
Me.Catzoek.SetFocus
Exit Sub
End If
Exit_Zoekknop_Click:
Exit Sub
End Sub
In brief the idea of how it works.
In a form I have 5 combo's for search criteria which are combined to a search string.
When hit the search button the code below uses this string as the WHERE function.
All goes as planned, however when leaving the search form, the search criteria, also when all empty, is put on the first record of the table attached to the searchform!
What can be the problem here?
Here is the code:
Private Sub Zoekknop_Click()
Dim strSQL As String
Dim strWhere As String
strWhere = Zoeken_op()
strSQL = "SELECT DISTINCTROW Organisaties.Plaats, " & _
"Organisaties.Doelgroep, Organisaties.Categorie, " & _
"Organisaties.Subcategorie, Organisaties.Trefwoord, " & _
"Organisaties.Organisatienaam, Organisaties.OrganisatieID as Recordnr " & _
"FROM Organisaties " & _
"WHERE " & strWhere & ";"
Me!Zoekresultaat.Form.RecordSource = strSQL
Me!Zoekresultaat.Form.Requery
If Me.Zoekresultaat.Form.RecordsetClone.RecordCount = 0 Then
DoCmd.Hourglass False
MsgBox "Er zijn geen aktiviteiten die voldoen aan de zoek criteria.", vbInformation
Me.Catzoek.SetFocus
Exit Sub
End If
Exit_Zoekknop_Click:
Exit Sub
End Sub