Query Field with Multiple Selection Combo Box (1 Viewer)

JithuAccess

Member
Local time
Today, 04:08
Joined
Mar 3, 2020
Messages
297
Hello Guys,

I have a multiple selection Combo Box in my Table:

1615572057527.png


These are the data in my Table:

1615572083299.png


I have created a query to Display only those Records where Countries are Canada and USA. This is my Query
1615572161367.png


And the Query Returns Nothing.

Could you please let me know how to solve this?

Thanks
 

JithuAccess

Member
Local time
Today, 04:08
Joined
Mar 3, 2020
Messages
297
When I gave in the Query Criteria as:

1615573670015.png


I am getting the Query Result like:

1615573695179.png


But I just need

1615573716157.png


Thanks
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 06:08
Joined
Feb 19, 2002
Messages
43,266
That is correct based on your criteria. That's what happens when you use this abomination feature. It is best to use the old tried and true 1-m relationship and a subform rather than a multi-select list box. That way you can create a query that only returns the records you want.

PS, how can you have one postal code but multiple countries?
 

JithuAccess

Member
Local time
Today, 04:08
Joined
Mar 3, 2020
Messages
297
That is correct based on your criteria. That's what happens when you use this abomination feature. It is best to use the old tried and true 1-m relationship and a subform rather than a multi-select list box. That way you can create a query that only returns the records you want.

PS, how can you have one postal code but multiple countries?
Many thanks for your reply. Could you kindly let me know how to use a subform instead of using a multi select combo box? Sorry I have no idea how to use this.

Currently I am using a very unprofessional method. I have added another field in the main Table next to countries "strCountries For Query" and then copy and paste whatever the data in the field Countries. And I have add a bounded Text Box (linked with strCountries For Query). For a new Entry, I put this VBA Code in the AfterUpdate Event of "StrCountries"

Code:
Dim strText As String
strText = Me.strCountries.Text

Me.strCountries_for_Query = strText

PS, how can you have one postal code but multiple countries?

This is a Sample Table I just put some random values. Please ignore this part.

Thanks a lot for your Help
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 06:08
Joined
Feb 19, 2002
Messages
43,266
Here's an example of a main form with a subform. This example is actually more sophisticated than what you need since the example shows a mainform with two related subforms. The first subform is members and the second is dependents. When you click on a row in the members subform, the dependents subform is synced to show only that members dependents.

mainform/subform examples are everywhere. They are used whenever you have a 1-m relationship. There is no trick here the master/child links on the first subform control are all that Access needs to sync the subform. The example was designed to show how to have a second dependent subform.
 

Attachments

  • MasterChildLinks_20210315.zip
    2.9 MB · Views: 268

JithuAccess

Member
Local time
Today, 04:08
Joined
Mar 3, 2020
Messages
297
Here's an example of a main form with a subform. This example is actually more sophisticated than what you need since the example shows a mainform with two related subforms. The first subform is members and the second is dependents. When you click on a row in the members subform, the dependents subform is synced to show only that members dependents.

mainform/subform examples are everywhere. They are used whenever you have a 1-m relationship. There is no trick here the master/child links on the first subform control are all that Access needs to sync the subform. The example was designed to show how to have a second dependent subform.
Thanks a lot. Let me check this
 

Users who are viewing this thread

Top Bottom