Eljefegeneo
Still trying to learn
- Local time
- Today, 15:28
- Joined
- Jan 10, 2011
- Messages
- 902
Probably another novice question, but I am stumped again.
I have made a simple search form which is used to set the criteria for a query. When I run the query without putting any search criteria into the search form it only selects about 70% of the records. There are about 20K records that should meet the criteria but I only get about 14K. I am wondering what I am doing wrong. It may be that some of the fields in the query do not have any data, i.e. a telephone number? Initially I use OR instead of AND but that just gave me all of the records regardless of the criteria. Thanks.
SELECT tblMain.ClientID, tblMain.Surname, tblMain.Organization, tblMain.ProgramTitle, tblMain.City, tblMain.State, tblMain.Zip4, tblMain.Telephone
FROM tblMain
WHERE (((tblMain.Surname) Like "*" & [Forms]![frmJeffSearch]![txtSurname]) AND ((tblMain.Organization) Like "*" & [Forms]![frmJeffSearch]![txtOrganization] & "*") AND ((tblMain.ProgramTitle) Like "*" & [Forms]![frmJeffSearch]![txtProgramTitle] & "*") AND ((tblMain.City) Like "*" & [Forms]![frmJeffSearch]![txtCity] & "*") AND ((tblMain.State) Like "*" & [forms]![frmJeffSearch]![cboState]) AND ((tblMain.Zip4) Like [Forms]![frmJeffSearch]![txtZip4] & "*") AND ((tblMain.Telephone) Like "(" & [forms]![frmJeffSearch]![txtAreaCode] & "*"));
I have made a simple search form which is used to set the criteria for a query. When I run the query without putting any search criteria into the search form it only selects about 70% of the records. There are about 20K records that should meet the criteria but I only get about 14K. I am wondering what I am doing wrong. It may be that some of the fields in the query do not have any data, i.e. a telephone number? Initially I use OR instead of AND but that just gave me all of the records regardless of the criteria. Thanks.
SELECT tblMain.ClientID, tblMain.Surname, tblMain.Organization, tblMain.ProgramTitle, tblMain.City, tblMain.State, tblMain.Zip4, tblMain.Telephone
FROM tblMain
WHERE (((tblMain.Surname) Like "*" & [Forms]![frmJeffSearch]![txtSurname]) AND ((tblMain.Organization) Like "*" & [Forms]![frmJeffSearch]![txtOrganization] & "*") AND ((tblMain.ProgramTitle) Like "*" & [Forms]![frmJeffSearch]![txtProgramTitle] & "*") AND ((tblMain.City) Like "*" & [Forms]![frmJeffSearch]![txtCity] & "*") AND ((tblMain.State) Like "*" & [forms]![frmJeffSearch]![cboState]) AND ((tblMain.Zip4) Like [Forms]![frmJeffSearch]![txtZip4] & "*") AND ((tblMain.Telephone) Like "(" & [forms]![frmJeffSearch]![txtAreaCode] & "*"));