cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Mickow
Helper II
Helper II

Combo box validation: empty v blank

Hi, please could you advise me on combo box validation? I have created 6 combo boxes - 3 pairs of code and country. 

I need to check whether:

 

1.Always, the first pair of codes and country is selected. (the first pair is mandatory for this request, another two pairs are optional)

 

The button on the bottom (create new request) should be disabled only if first pair of combo boxes is not selected.

 

2.Check whether provided code and country exist in my data source (excel on OneDrive). This is really important as I have to allow users to search/type/paste code, and the list is long. While my app was tested - it appeared that testers could have pasted anything, and it was not validated anyhow (well, the dropdown did not appear, but they didn't pay attention). So they were submitting empty requests. 

 

I was trying to try simple text boxes, but there are some obstacles that I don't know how to overcome. If there is no value selected and if the value is non-existing -- I get the same message. I used IsEmpty, but it's not what I would expect. If there is no value  - there should be no message, but when the value is incorrect - the message should be displayed. 

 

Please take a look on the screenshot of my app.

 

111111.png

6 REPLIES 6
Alex_10
Super User
Super User

@Mickow 

 

// disabled both are not selected or error message visible

button.DisplayMode = 

If(IsBlank(ComboBox1.Selected.Value) || IsBlank(ComboBox2.Selected.Value) || labelErrorMessage.Visible, DisplayMode.Disabled , DisplayMode.Edit)

 

 

labelErrorMessage.visible =

!IsBlank(ComboBox1.Selected.Value) &&
!IsBlank(ComboBox2.Selected.Value) &&
!IsBlank(LookUp(YourDataSource, CodeColumn.Value = ComboBox1.Selected.Value && CountryColumn.Value = ComboBox2.Selected.Value))

 

if user selects codeCombobox=1 and countryCombobox=a and there is a single record where code=1 and country=a, error is displayed.

If there is a record where code=1 and country=b, error is not shown.

Hi @Alex_10 thank you for your help! The first part already helped me a lot. Could you please explain from the second code what will be:

 

YourDataSource - I do have one excel file with both - Code and Country in two different, defined tables there (respectively TableXCX and TableCountry). As I'm typing formula, I cannot choose from the prompt the whole excel as source, but only singe table. Can/should I concatenate them somehow or use slightly different formula?

 

CodeColumn.Value, CountryColumn.Value  - I'm confused what should I type here. My Tables headers in this excel file are respectively: X_Code_ID and CountryCode. Should it look like: X_Code_ID.X_Code_ID?

 

Thnaks!

 

Alex_10
Super User
Super User

@Mickow 

each table is a datasource. so you have 2 datasources.

 

You have TableXCX and TableCountry.

How do these tables relate (depend on) each other? (primary/foreign keys?)

@Alex_10 hey they don't depend on each other. Those are two separate tables.

Alex_10
Super User
Super User

@Mickow 

 

labelErrorMessage.visible =

!IsBlank(ComboBox1.Selected.Value) &&
!IsBlank(ComboBox2.Selected.Value) &&
!IsBlank(LookUp(TableXCX , CodeColumnName.Value = ComboBox1.Selected.Value)) &&

!IsBlank(LookUp(TableCountry, CountryColumnName.Value = ComboBox2.Selected.Value))

Thanks, but it does not work as I suspected. I will leave it as it is and at some point it is fine too (more explanation to requesters needed). All formulas I've tried cannot handle the empty combo box vs. incorrect value in the combo box. If one way they work (against incorrect), it cannot handle the other (empty). 

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,584)