L
Laurie
I'm trying to learn to do simple sql stuff, and I'm stumped. I have an
unbound form, with unbound controls, to input criteria for a query.
When I enter criteria, I only receive records that have unique entries
in the given field(s). For example, if I request a list of records for
cities that start with "S", I will get only one record for each unique
city name. Same for company name - it only shows one for each unique
company name. Clearly something is written wrong in my code. Query looks
like this:
SELECT Companies.CompanyName, Companies.ContactFirstName,
Companies.ContactLastName, Companies.City, Companies.State,
Companies.PhoneNumber, Companies.CompanyID
FROM Companies
WHERE (((Companies.CompanyName) Like
IIf(IsNull([Forms]![Search_Form]![CompanyName]),"*",[Forms]![Search_Form]![CompanyName]
& "*")) AND ((Companies.ContactFirstName) Like
IIf(IsNull([Forms]![Search_Form]![ContactFirstName]),"*",[Forms]![Search_Form]![ContactFirstName]
& "*")) AND ((Companies.ContactLastName) Like
IIf(IsNull([Forms]![Search_Form]![ContactLastName]),"*",[Forms]![Search_Form]![ContactLastName]
& "*")) AND ((Companies.City) Like
IIf(IsNull([Forms]![Search_Form]![City]),"*",[Forms]![Search_Form]![City]
& "*")) AND ((Companies.City) Like
IIf(IsNull([Forms]![Search_Form]![State]),"*",[Forms]![Search_Form]![State]
& "*")) AND ((Companies.State)
Any help, please? Thank you very much for your input.
unbound form, with unbound controls, to input criteria for a query.
When I enter criteria, I only receive records that have unique entries
in the given field(s). For example, if I request a list of records for
cities that start with "S", I will get only one record for each unique
city name. Same for company name - it only shows one for each unique
company name. Clearly something is written wrong in my code. Query looks
like this:
SELECT Companies.CompanyName, Companies.ContactFirstName,
Companies.ContactLastName, Companies.City, Companies.State,
Companies.PhoneNumber, Companies.CompanyID
FROM Companies
WHERE (((Companies.CompanyName) Like
IIf(IsNull([Forms]![Search_Form]![CompanyName]),"*",[Forms]![Search_Form]![CompanyName]
& "*")) AND ((Companies.ContactFirstName) Like
IIf(IsNull([Forms]![Search_Form]![ContactFirstName]),"*",[Forms]![Search_Form]![ContactFirstName]
& "*")) AND ((Companies.ContactLastName) Like
IIf(IsNull([Forms]![Search_Form]![ContactLastName]),"*",[Forms]![Search_Form]![ContactLastName]
& "*")) AND ((Companies.City) Like
IIf(IsNull([Forms]![Search_Form]![City]),"*",[Forms]![Search_Form]![City]
& "*")) AND ((Companies.City) Like
IIf(IsNull([Forms]![Search_Form]![State]),"*",[Forms]![Search_Form]![State]
& "*")) AND ((Companies.State)
Any help, please? Thank you very much for your input.