Hi all,
I have a database of 600+ records containing 12 columns of data per client, things like Name, Contact Number, Email, Postal Code, How they heard of us, Buyer profile etc.
I want users of the database to be able to 'build their own query' using an unbound form (with the 12 data fields) that prompts the criteria for the records they wish to view. For example, a user may be interested in seeing all 'Owners' that are in the Postal code '1234', or the clients from the suburb 'Sydney' that heard of us through 'Word of Mouth', (plus possibly even more specific search criteria). The idea is that the form allows them to choose many flexible combinations of criteria.
What I need is for the query to leave the criteria blank for any data/field not specifically requested by the user. Or in other words, for example, If the user leaves the 'Client Name' blank on the form, don't exclude all records with Non-Blank 'Client Name' from the query results...rather it should just ignore this as a criteria.
At the moment I'm getting zero query results unless I fill in every field on the form and it matches a record exactly.
I've searched and searched for solutions, and I'm thinking I may get lucky with some kind of IF statement within the SQL of the query. Something which sets the criteria of a column to match the input of the form, IF it wasn't left blank by the user.
Either that or some kind of VBA code that customises the query criteria based on how many of the fields on the form were given criteria.
Bonus Brownie Points: If on certain Memo fields, the inputted string from the user just has to be contained within the memo, rather than match it completely.
Thanks for any help
I have a database of 600+ records containing 12 columns of data per client, things like Name, Contact Number, Email, Postal Code, How they heard of us, Buyer profile etc.
I want users of the database to be able to 'build their own query' using an unbound form (with the 12 data fields) that prompts the criteria for the records they wish to view. For example, a user may be interested in seeing all 'Owners' that are in the Postal code '1234', or the clients from the suburb 'Sydney' that heard of us through 'Word of Mouth', (plus possibly even more specific search criteria). The idea is that the form allows them to choose many flexible combinations of criteria.
What I need is for the query to leave the criteria blank for any data/field not specifically requested by the user. Or in other words, for example, If the user leaves the 'Client Name' blank on the form, don't exclude all records with Non-Blank 'Client Name' from the query results...rather it should just ignore this as a criteria.
At the moment I'm getting zero query results unless I fill in every field on the form and it matches a record exactly.
I've searched and searched for solutions, and I'm thinking I may get lucky with some kind of IF statement within the SQL of the query. Something which sets the criteria of a column to match the input of the form, IF it wasn't left blank by the user.
Either that or some kind of VBA code that customises the query criteria based on how many of the fields on the form were given criteria.
Bonus Brownie Points: If on certain Memo fields, the inputted string from the user just has to be contained within the memo, rather than match it completely.
Thanks for any help