Good day,
I am trying to create a form that could be used by the users to create their own queries if needed. The form is based on the example given by Stan Leszynski in his book Access 97 Expert Solutions. I have changed the form to include a list box with the property "Multi select" set to Extended so that the user should be able to choose only the fields he/she requires.
There is five distinct fields on the form of which the last three is repeated four times. I will be adding a sixth field that would be used as a connector (AND or OR)
The fields are as follow.
1. Combo box to select the table or query too be used in the query.
2. List box with the field names of the chosen table/query.
3. Combo box with the field names too be used in the criteria.
4. Combo box with Comparison criteria. (<, =, > ect.)
5. A value field. To complete the criteria. E.g. a date, a number or some text.
I have two questions.
How do I code the following. If I select say four fields in the list box to be included in the the query, tried "& Me!List5.Value &" and it does not work. How would I include, in code, quotation marks in the Value field if text is entered. Access would normally correct the information if a date or number is entered, but, if text is entered the word is enclosed by square brackets. E.g.
SELECT * FROM qryCustOrder WHERE (((qryCustOrder.CompanyName)=[abc])); instead of
SELECT * FROM qryCustOrder WHERE (((qryCustOrder.CompanyName)="abc"
);
Thank you for your time.
Hennie
I am trying to create a form that could be used by the users to create their own queries if needed. The form is based on the example given by Stan Leszynski in his book Access 97 Expert Solutions. I have changed the form to include a list box with the property "Multi select" set to Extended so that the user should be able to choose only the fields he/she requires.
There is five distinct fields on the form of which the last three is repeated four times. I will be adding a sixth field that would be used as a connector (AND or OR)
The fields are as follow.
1. Combo box to select the table or query too be used in the query.
2. List box with the field names of the chosen table/query.
3. Combo box with the field names too be used in the criteria.
4. Combo box with Comparison criteria. (<, =, > ect.)
5. A value field. To complete the criteria. E.g. a date, a number or some text.
I have two questions.
How do I code the following. If I select say four fields in the list box to be included in the the query, tried "& Me!List5.Value &" and it does not work. How would I include, in code, quotation marks in the Value field if text is entered. Access would normally correct the information if a date or number is entered, but, if text is entered the word is enclosed by square brackets. E.g.
SELECT * FROM qryCustOrder WHERE (((qryCustOrder.CompanyName)=[abc])); instead of
SELECT * FROM qryCustOrder WHERE (((qryCustOrder.CompanyName)="abc"
Thank you for your time.
Hennie