i have made a form for searching and i took the code from the Thread702-563930 my code now its look like this:
Private Sub cmdSearch_Click()
Dim strSQL As String, strOrder As String, strWhere As String
Dim dbNm As Database
Dim qryDef As QueryDef
Set dbNm = CurrentDb()
strSQL = "SELECT Åðþíõìï, ¼íïìá, Ðåñéï÷Þ,Äéåýèõíóç, Ôê " & _
"FROM tblCustomers"
strWhere = "WHERE"
' set where clause conditions
If Not IsNull(Me.txtFName) Then
strWhere = strWhere & " (tblCustomers.Åðþíõìï) Like '" & Me.txtFName & "*' AND "
End If
If Not IsNull(Me.txtLName) Then
strWhere = strWhere & " (tblCustomers.¼íïìá) Like '" & Me.txtLName & "*' AND"
End If
If Not IsNull(Me.txtCity) Then
strWhere = strWhere & " (tblCustomers.Ðåñéï÷Þ) Like '" & Me.txtCity & "*' AND"
End If
If Not IsNull(Me.txtAddress) Then
strWhere = strWhere & " (tblCustomers.Äéåýèõíóç) Like '" & Me.txtCity & "*' AND"
End If
If Not IsNull(Me.txtState) Then
strWhere = strWhere & " (tblCustomers.Ôê) Like '" & Me.txtState & "*' AND"
End If
strWhere = Mid(strWhere, 1, Len(strWhere) - 5) ' remove ' and'
Set qryDef = dbNm.QueryDefs("qrycustom"
qryDef.SQL = strSQL & " " & strWhere & ""
DoCmd.OpenReport "rptcustom", acViewPreview
End Sub
and i want if no one field is fill to have a msgbox to say "please fill at list one field"
and if there is no records after the search another msgbox to say no records found.
can anyone help me pls?
Private Sub cmdSearch_Click()
Dim strSQL As String, strOrder As String, strWhere As String
Dim dbNm As Database
Dim qryDef As QueryDef
Set dbNm = CurrentDb()
strSQL = "SELECT Åðþíõìï, ¼íïìá, Ðåñéï÷Þ,Äéåýèõíóç, Ôê " & _
"FROM tblCustomers"
strWhere = "WHERE"
' set where clause conditions
If Not IsNull(Me.txtFName) Then
strWhere = strWhere & " (tblCustomers.Åðþíõìï) Like '" & Me.txtFName & "*' AND "
End If
If Not IsNull(Me.txtLName) Then
strWhere = strWhere & " (tblCustomers.¼íïìá) Like '" & Me.txtLName & "*' AND"
End If
If Not IsNull(Me.txtCity) Then
strWhere = strWhere & " (tblCustomers.Ðåñéï÷Þ) Like '" & Me.txtCity & "*' AND"
End If
If Not IsNull(Me.txtAddress) Then
strWhere = strWhere & " (tblCustomers.Äéåýèõíóç) Like '" & Me.txtCity & "*' AND"
End If
If Not IsNull(Me.txtState) Then
strWhere = strWhere & " (tblCustomers.Ôê) Like '" & Me.txtState & "*' AND"
End If
strWhere = Mid(strWhere, 1, Len(strWhere) - 5) ' remove ' and'
Set qryDef = dbNm.QueryDefs("qrycustom"
qryDef.SQL = strSQL & " " & strWhere & ""
DoCmd.OpenReport "rptcustom", acViewPreview
End Sub
and i want if no one field is fill to have a msgbox to say "please fill at list one field"
and if there is no records after the search another msgbox to say no records found.
can anyone help me pls?