Forum Discussion
CristinaRSP
Mar 21, 2022Copper Contributor
Combo box
Good day I have a table with data, and I am trying to run a query with the criteria from a combo box. When I run the query I get no data. I don't know how to figure out what's wrong. Also I don't ...
CristinaRSP
Mar 21, 2022Copper Contributor
Thanks for your response.
This is the SQL.
SELECT DISTINCT RTI.[Cause of Accident], RTI.full_name, RTI.sex
FROM RTI
WHERE (((RTI.[Cause of Accident])=[Forms]![Preview Reports]![Combo100]));
I have a table with list of causes of accidents, and a table with Data on crashes.
The query returns no data.
I would be grateful for your assistance.
Cristina
This is the SQL.
SELECT DISTINCT RTI.[Cause of Accident], RTI.full_name, RTI.sex
FROM RTI
WHERE (((RTI.[Cause of Accident])=[Forms]![Preview Reports]![Combo100]));
I have a table with list of causes of accidents, and a table with Data on crashes.
The query returns no data.
I would be grateful for your assistance.
Cristina
George_Hepworth
Mar 21, 2022Silver Contributor
What is the rowsource for the combo box, [Forms]![Preview Reports]![Combo100]
And we try to rename controls instead of accepting the default assigned by Access, "Combo100" apparently is based on a lookup table of accident causes, so give it that name: "cboAccidentCause" or similar.
My guess is that there is probably a number field involved, and not just the text field indicated, but we have to see that as well.
- CristinaRSPMar 22, 2022Copper ContributorThank you. I renamed the Combo Box and removed the ID auto number from the source table of the combo box, (TblCauseofaccident)and it worked. Thank you very much
- George_HepworthMar 22, 2022Silver ContributorThat's the opposite of what I would have suggested, unfortunately. The reason for the two columns in a lookup table is that the ID, which is the Primary Key for the table, is unique and never changes. The text value, on the other hand, can be altered. The way you have it now, if you decide that "DUI", for example, should be "DWUI" (driving while under the influence) you'll suddenly have two different values that ostensibly mean the same thing.
What I meant when I said, "...we have to see that as well", was that you'd share that with us so we could give you more specific suggestions.