cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Edvhdy
Helper III
Helper III

disable a button relative to a date

Hello,

I have a daily entry app. wants the user to be able to add entries from the previous month up to the 5th of the current month.

 

Example: We are August 4th, the user can register an entry for the month of July. But if it's August 6, he can't catch data for the month of July.

 

So I put a condition in the DisplayMode of the validate button.

if (Text (_dateSelected; "[$ -fr] mmmm yyyy") <> Text (Now (); "[$ -fr] mmmm yyyy"); DisplayMode.Disabled; DisplayMode.Edit)

 

but how to set up the possibility for the user to record entries from the previous month until the 5th of the current month?

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
mdevaney
Super User
Super User

@Edvhdy 
Make the user select a date using a DatePicker.  Then put this code in the DisplayMode of your validate button.

 

If(
    DatePicker1.SelectedDate <= Date(Year(Today()),Month(Today()), 5)
    And DatePicker1.SelectedDate >= Date(Year(Today()),Month(Today())-1, 1),
    DisplayMode.Edit,
    DisplayMode.View
)

 


---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

2 REPLIES 2
mdevaney
Super User
Super User

@Edvhdy 
Make the user select a date using a DatePicker.  Then put this code in the DisplayMode of your validate button.

 

If(
    DatePicker1.SelectedDate <= Date(Year(Today()),Month(Today()), 5)
    And DatePicker1.SelectedDate >= Date(Year(Today()),Month(Today())-1, 1),
    DisplayMode.Edit,
    DisplayMode.View
)

 


---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

hi @mdevaney ,

 

your code seems to work thank you for your help and your reactivity

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,596)