Private Sub DodajUslov(Vrijednost, ImePolja As String, Kriterija As String, Brojac As Integer) If IsNumeric(Vrijednost) = False Then Vrijednost = Vrijednost & Chr(42) End If If IsDate(Vrijednost) Then Vrijednost = "#" & Vrijednost & "#" End If If Vrijednost <> "" Then If Brojac > 0 Then Kriterija = Kriterija & " and " End If Kriterija = (Kriterija & ImePolja & " Like " & Chr(39) & Vrijednost & Chr(39)) Brojac = Brojac + 1 End If End Sub Private Sub TaterZaPretragu_Click() Dim MySQL As String, Kriterija As String, RekordSours As String Dim ImepoljaT As String, ImePolja As String, ImeTabele As String Dim Brojac As Integer, I As Integer ImeTabele = "ImeTabele iz koje vrsimo pretragu" ' MySQL = "SELECT * FROM " & ImeTabele & " WHERE " For I = 1 To 6 ' 6 je broj polja 'Ovo su imena polja u tabeli iz koje vrsimo pretragu ImepoljaT = Choose(I, "ImePolja1", "ImePolja2", "ImePolja3", "Imepolja4") 'Ovo su imena polja na formi u koja upisujemo kriterije pretrage ImePolja = Choose(I, "ImePolja1", "ImePolja2", "ImePolja3", "Imepolja4") DodajUslov Me(ImePolja), ImepoljaT, Kriterija, Brojac Next I If Kriterija = "" Then Kriterija = "True" End If RekordSours = MySQL & Kriterija Me.RecordSource = RekordSours If Me.RecordsetClone.RecordCount = 0 Then MsgBox "Nema podataka po ovom kriteriju" End If End Sub