andrewhoddie
Board Regular
- Joined
- Dec 21, 2008
- Messages
- 114
Hi
I have a form called Customer Enquiry which feeds into a table called Customerdata.
What I am trying to do is create a search form where I have an unbound text box called criteria to enter the search criteria and a button to click to search the records. I have a further sub form called ServiceUsersSearchList where the results are displayed.
I am using the following codes:
Private Sub Form_Open(Cancel As Integer)
SCriteria = "SELECT * FROM Customerdata "
Forms!Search!ServiceUsersSearchList.Form.RecordSource = SCriteria
Forms!Search!ServiceUsersSearchList.Form.Requery
End Sub
Private Sub Command2_Click()
If Criteria <> "" Then
SCriteria = "(surname LIKE(" & Chr(34) & "*" & Criteria & "*" & Chr(34) & _
") Or Orchardnumber LIKE(" & Chr(34) & "*" & Criteria & "*" & Chr(34) & ") Or Forename LIKE(" & Chr(34) & "*" & Criteria & "*" & Chr(34) & ") Or Add1 LIKE(" & Chr(34) & "*" & Criteria & "*" & Chr(34) & ") Or Street Like(" & Chr(34) & "*" & Criteria & "*" & Chr(34) & ")) And "
Else
SCriteria = ""
End If
Forms!Search!ServiceUsersSearchList.Form.RecordSource = TCriteria
Forms!Search!ServiceUsersSearchList.Form.Requery
End Sub
When I click the search button I get all fields showing #Name ?
Is anyone able to assist me in correcting this issue.
Many thanks
Andrew
I have a form called Customer Enquiry which feeds into a table called Customerdata.
What I am trying to do is create a search form where I have an unbound text box called criteria to enter the search criteria and a button to click to search the records. I have a further sub form called ServiceUsersSearchList where the results are displayed.
I am using the following codes:
Private Sub Form_Open(Cancel As Integer)
SCriteria = "SELECT * FROM Customerdata "
Forms!Search!ServiceUsersSearchList.Form.RecordSource = SCriteria
Forms!Search!ServiceUsersSearchList.Form.Requery
End Sub
Private Sub Command2_Click()
If Criteria <> "" Then
SCriteria = "(surname LIKE(" & Chr(34) & "*" & Criteria & "*" & Chr(34) & _
") Or Orchardnumber LIKE(" & Chr(34) & "*" & Criteria & "*" & Chr(34) & ") Or Forename LIKE(" & Chr(34) & "*" & Criteria & "*" & Chr(34) & ") Or Add1 LIKE(" & Chr(34) & "*" & Criteria & "*" & Chr(34) & ") Or Street Like(" & Chr(34) & "*" & Criteria & "*" & Chr(34) & ")) And "
Else
SCriteria = ""
End If
Forms!Search!ServiceUsersSearchList.Form.RecordSource = TCriteria
Forms!Search!ServiceUsersSearchList.Form.Requery
End Sub
When I click the search button I get all fields showing #Name ?
Is anyone able to assist me in correcting this issue.
Many thanks
Andrew