The error you are experiencing with the MS interface to this newsgroup is
widespread, which is why we are getting so many multiple posts right now.
If you are using a value list for the combo box's RowSourceType, and the
values are not a set which is fixed in the external world (days of the week
or months of the year are examples of such sets), then you are storing data
as part of the form definition, whereas data should only be stored as values
at column positions in rows in tables. That way integrity can be ensured.
Taking a simple example, lets say the query is based on a table
Questionnaire in which you have a column named Answer to which you are
applying the combo box's value as a parameter, and which can have legitimate
values of "Yes", "No" or "Don't Know", then you should also have a table
Answers with columns Answer (the primary key) and AnswerOrder, the last
merely being to control the order in which the three options appear in the
list, so it might contain the following Rows:
Yes 1
No 2
Don't Know 3
This table should be related to Questionnaire on the Answer columns and
referential integrity enforced. This ensures that only legitimate values can
be entered in the Answer column in Questionnaire. As 'natural' keys are used
here rather than 'surrogate' numeric keys, cascade updates should also be
enforced.
The RowSourceType property of the combo box would now be Table/Query and the
RowSource property would be:
SELECT Answer FROM Answers ORDER BY AnswerOrder;
The query would then be something like this:
SELECT *
FROM Questionnaire
WHERE Answer = Forms!YourForm!cboAnswer;
Or if you want to make the parameter optional, returning all rows if no item
is selected in the combo box:
SELECT *
FROM Questionnaire
WHERE Answer = Forms!YourForm!cboAnswer
OR Forms!YourForm!cboAnswer IS NULL;
If the form containing the combo box is bound to this query, then in the
combo box's AfterUpdate event procedure you'd requery the form with:
Me.Requery
Or if it’s an unbound dialogue form then you'd open another form or report
based on the query, probably with a button on the dialogue form. You could
simply open the query in datasheet view, but a form or report is better,
enabling you to control the presentation of the data far more, and giving a
generally more professional appearance to the application.
Ken Sheridan
Stafford, England