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 Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,810)