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 / How to Disable DELETE ...
Power Apps
Answered

How to Disable DELETE button on an Edit Form when adding new record ?

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I have the following:

Gallery with Add button (+)

Edit Form with the following buttons:

Cancel (X),

Delete (name is IconDelete1_1 on EditScreen1)

Save

On the Gallery, when I click the Add button to add a new record, how can I disable the Delete button on the Edit Form ?

 

This is of course to prevent the user from attempting to Delete a non-existent record (SQL Server back end). From what I can tell, you need to use UpdateContext() and so on.

I've tried multiple different syntax's and so on, but to no avail.
Categories:
  • Venxir Profile Picture
    125 on at

    I assume that your Add button will invoke a NewForm(<FormName>)?

     

    Then you should use the formmode of your Edit Form.

     

    Just disable the delete button when Form.Mode = FormMode.New, If you edit an existing record the mode will be Edit and when vieweing a record the mode will be View.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    "I assume that your Add button will invoke a NewForm()?"

    Correct.

    Then you should use the formmode of your Edit Form."

    "Just disable the delete button when Form.Mode = FormMode.New,"

     

    Sooo ... how do I do that ? What is the code/syntax to actuallyDisable the DELETE button ... and where would I put it?

    Is there an event when the Edit Form opens ? thx

  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @Anonymous

     

    Select your Delete button and change its Display Mode property to:

     

    If(
     Form1.Mode = FormMode.Edit,
     DisplayMode.Edit,
     DisplayMode.Disabled
    )

    Form1 is the name of your form

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Martynas
    OK ... that works. Thank you.

    Note:
    This is what was in the Delete button DisplayMode property:

     

    If(!IsBlank(BrowseGallery1.Selected) && DataSourceInfo('[NEM].[ztblNEM2Enh]', DataSourceInfo.DeletePermission), DisplayMode.Edit, DisplayMode.Disabled)

     

    where [NEM].[ztblNEM2Enh] is a table in my SQL Server back end.


    It would seem that code (generated when I let PA create the app) should Disable the button, but it's not. I think that is because there is always an item 'selected' in the BrowseGallery1.

     

    I tried just If(!IsBlank(BrowseGallery1.Selected), DisplayMode.Edit, DisplayMode.Disabled) ... that does not work either.
    Why do you suppose that is ?

     

    Nonetheless ... I'm using the code you provided. I'm not really concerned with 'DeletePermission' in this app.

    Appreciate the help.

     

    Funny ... I've been working 24x7x365 with Microsoft Access / VBA for 25 years. Things like this are second nature. BUT ... the syntax in PA is quite different. BOOM !

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 July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 394 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 324 Most Valuable Professional

Last 30 days Overall leaderboard