onchange query = if .me field matches anything in ref_nationality table then msgbox

splreece

Registered User.
Local time
Today, 07:47
Joined
Jun 2, 2016
Messages
40
Morning all,

I have been able to find onchange examples and if else then working formulae but am struggling with finding an onchange example where the on change queries the text string against a table and if matches then produces a msgbox.

I have field "txt_tag1" which is a combobox of all countries.
I have a table "ref_exclusions" which is a table listing all countries excluded


I need the ability to display a msgbox if the user selects an excluded country from the list in the combo box (so onchange command in the combo box).

I need them to be allowed to select the country, just a disclaimer bounces up first.

any thoughts?
 
1. you say your control, txt_tag1 is a combo box. The prefix txt is meant for text boxes.
cbo is the prefix for combo box , cbo_tag1 would be the correct label to help self identify objects on a form.

2 you can either :
a. put ALL countries in 1 table and a 2nd field [exclude] would be set to true. Only use the false ones.
or
b. keep your 2 separate table, create an outer join query , and exclude the items in the exclusion table.

I prefer the A method
 
thanks for the advice Ranman, and yep I have it as cbo, it was my typing skills failing me on the query.

I wasn't sure about the logic behind the search and show side of the process.

So once I have the completed list, how would I actually structure the onchange action to either interrogate the table or the query?
 
Bring in the two fields into the combo, countries and excluded. Hide the second field.
In the after update event of cmbTag1 you can check the value of excluded;

If Me.cmbTag1.Column(1) = "Excluded" Then msg box....

Columns in combo's start being numbered at 0 so the second column is 1.
 
Bring in the two fields into the combo, countries and excluded. Hide the second field.
In the after update event of cmbTag1 you can check the value of excluded;

If Me.cmbTag1.Column(1) = "Excluded" Then msg box....

Columns in combo's start being numbered at 0 so the second column is 1.

Ahhh that makes perfect sense... and is a lot simpler than I thought it would be.

for some reason I thought I may have to do some sort of find/match formula (excel style fiddly thing).
 

Users who are viewing this thread

Back
Top Bottom