web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Button DisplayMode wit...
Power Apps
Answered

Button DisplayMode with DatePicker

(0) ShareShare
ReportReport
Posted on by 308

Hi Power Apps community,

 

I am building a vacation app that let people choose their leave and return date. However, there are certain rules such as: an employee have a maximum of 20 days to go on vacation. I have 2 Datepickers, which Datepicker 1 represents the leave date and Datepicker 2 represents the return date. I have also put a label that display how many days are left for an user.

I want to make the displaymode of the submit button disabled if the total days of vacation is more than 20. I have entered my code in the OnChange method of Datepicker2. It doesn't show any error in the code, but the submit button doesn't turn disabled when the total days pass 20. This is my current code:

 

If(DateDiff(DatePicker1.SelectedDate,DatePicker2.SelectedDate,Days) > Value(txtTotalVacDaysLeft.Text), UpdateContext({PopUp:true}); btnVacSubmit.DisplayMode.Disabled, UpdateContext({PopUp:false}); btnVacSubmit.DisplayMode.Edit)

 

It would rely help me a lot solving this problem.

Categories:
I have the same question (0)
  • Verified answer
    Pstork1 Profile Picture
    69,599 Most Valuable Professional on at

    Use basically the same code you have now in the onChange event, but instead of setting the DisplayMode property of the button directly set a variable to the number of days you calculate.  Then set the displaymode of the button using the following.

    if(daysRequested>20,displayMode.Disabled,DisplayMode.Edit)

    You can't set the properties of another control on the screen using a behavior.  you can set a variable and then have the control react to the change in the value of the variable. 

  • JB0007 Profile Picture
    308 on at

    Thanks @Pstork1, it works now.

  • Boki Profile Picture
    16 on at

    I have a similar issue.
    I need to Save btn been disabled if a user selects the date more than Today(). You can see the screenshot, I don't have any error in the code, but I still have the Save btn available even the wrong date is selected.

    Screenshot_1.jpg

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 335 Most Valuable Professional

#2
11manish Profile Picture

11manish 165

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 96 Super User 2026 Season 1

Last 30 days Overall leaderboard