cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mx
Advocate III
Advocate III

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

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.
DatabaseMX ('mx')
Microsoft Access MVP
1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

Hi @mx

 

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

View solution in original post

4 REPLIES 4
Venxir
Resolver I
Resolver I

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.

mx
Advocate III
Advocate III

"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

DatabaseMX ('mx')
Microsoft Access MVP
Anonymous
Not applicable

Hi @mx

 

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

View solution in original post

@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 !

DatabaseMX ('mx')
Microsoft Access MVP

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

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.

Users online (1,315)