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 / Checkbox to turn off A...
Power Apps
Unanswered

Checkbox to turn off Auto Accriment and record last number (see pictures)

(0) ShareShare
ReportReport
Posted on by 301

Hi,

 

Im stuck on a problem that is driving me nuts, below you will see an image of my test app,

ShaneITAutomate_0-1620302714109.png

 

This app currently uses the labels to make sure the user is using the correct text format which is in the range ZZ000001 - ZZ999999,

 

The text input is collected into the gallery and also uses the following onchange in the text input

If(Value(Right(SampleIDTEXTINPUT.Text,5))>000001&&Value(Right(SampleIDTEXTINPUT.Text,5))<999999&&IsMatch(Left(SampleIDTEXTINPUT.Text,2),"ZZ"),true,Notify("**Format of entered value should like ZZ000001**",NotificationType.Error);Reset(SampleIDTEXTINPUT))

 

when the app loads the intial text input needs to be blank and im currently im using the following in the default of the text input

 

If(IsBlank(Gallery1.AllItems),"", NextSampleID.Text)

 

I need the checkbox added to turn off the text formating so the user can enter empty sampleID's and i also need for the app to record the last (next) sample id number for when they turn the checkbox off it starts working as normal, so they can turn it off and on again as in the following example but instead of the 000001 it should be ZZ000005 the text input always reverts back to ZZ000001 using the above default code

 

ShaneITAutomate_1-1620303271714.png

 

 

 

 

Categories:
I have the same question (0)
  • timl Profile Picture
    37,246 Super User 2026 Season 1 on at

    @ShaneITAutomate 

    Can you post the formula that you're using to determine the value in your NextSampleID textbox? That's probably where the problem lies.

  • ShaneITAutomate Profile Picture
    301 on at

    @timl wrote:

    @ShaneITAutomate 

    Can you post the formula that you're using to determine the value in your NextSampleID textbox? That's probably where the problem lies.


    Thats the next sampleID text

     

    Concatenate(First2Letters.Text,LastSubSampIDNumberPLus.Text)

     

    The First2Letters is Just a textinput with ZZ in it and the other one is below

     

    Text(LastSubSampIDNumber.Text + 1, "[$-en]000000")

     

    And that one in this is below

     

    Mid(LastSampleID.Text,3,100)

     

    Which gets it from

     

    Last(Gallery1.AllItems).SampleID

     

    Hence the loop to make the numbers accrue upwards. I just want it too show the next sample id it should be and on the first time be blank so they have to put the first sample id in

     

    Ie in the example above it should be showing ZZ000005 however if i press the checkbox it shows ZZ000001 again..

     

  • ShaneITAutomate Profile Picture
    301 on at

    Anyone?

  • timl Profile Picture
    37,246 Super User 2026 Season 1 on at

    @ShaneITAutomate 

    I'm guessing this is reverting to 1 because the last item in your gallery has a empty sample ID value. I would try filtering out the blank values:

    Last(Filter(Gallery1.AllItems, SampleID <> "").SampleID

     

  • timl Profile Picture
    37,246 Super User 2026 Season 1 on at

    @ShaneITAutomate 

    Thanks for your message, and apologies about the typo - there was missing closing bracket.

    Last(Filter(Gallery1.AllItems, SampleID <> "")).SampleID


    I think the key to this is to make sure that you can retrieve the ZZ000004 value, and hopefully the formula above will do this. Once this part works, everything should flow smoothly from that point onwards.

  • ShaneITAutomate Profile Picture
    301 on at

    Its doesnt, i would have replied earlier but the microsoft and html data stopping me from posting and banning me for 3600secs everytime for no reason really drives me nuts

     

    The Code just turns off the automatic accuring of text and values (Next sample Ids) and when turning the checkbox off and on it just keeps putting the same value over and over again (see pic below)

    ShaneITAutomate_0-1620392077058.png

     

  • timl Profile Picture
    37,246 Super User 2026 Season 1 on at

    @ShaneITAutomate 

    Looking at you screenshot, it appears that you are determining the 'Next Sample ID' correctly - ZZ800802 in this example.

    So presumably, I'm guessing that the fault lies in formula that's attached to 'Add button' button. Can you share the code that you have here? Are you calling Patch and referencing the correct sample ID?

  • ShaneITAutomate Profile Picture
    301 on at

    Its just a simple collect code,

    Collect(colTEST, {Title:"Title", SampleID:SampleIDTEXTINPUT.Text})
  • ShaneITAutomate Profile Picture
    301 on at

    But the code needs to collect from the text input, the others are just labels that seperate the text into Text and numbers and then concatenates  (this code is the next sampleID in that label)

    Concatenate(First2Letters.Text,LastSubSampIDNumberPLus.Text)

     

  • ShaneITAutomate Profile Picture
    301 on at

    I think your confused as to what im trying to do,

     

    I want the users to press the check box and the data isnt collected (i can use a simple a IF statment in the collect code and use a visibility code to make the text input hide.)  Thats fine.

     

    What i cannot figure out is somehow to save the Next Sample ID perhaps using a variable and if the user turns the check box off it changes whatever is in the text input box to the Next Sample ID (the text input under the checkbox and above the add button)

     

    @timl

     

    Also ive modified your code a little and now its swapping back and forth between two values.

     

    I.e

    ShaneITAutomate_0-1620531265852.png

     

     

    Heres the add code

     

     

    Collect(colTEST, {Title:"Title", 
    SampleID: If(TurnOFFCHECKBOX.Value = true,"",SampleIDTEXTINPUT.Text), NextSampleID:NextSampleID.Text})

     

     

     

    And heres the default code for the text input shown

     

     

     

    Last(Filter(Gallery1.AllItems, NextSampleID <> "")).NextSampleID

     

     

     

    It now goes back and forth between two values one of which is wrong, however it does keep the last sample ID

     

    Also if i start the app fresh and press the check box straight away the text and numbers go to the first value in the auto accuring code ie ZZ000001

     

    ie.

    ShaneITAutomate_1-1620531595426.png

     

     

    I want it to be blank at the start and force the user to put in a value so this onchange notify code works

     

     

    If(Value(Right(SampleIDTEXTINPUT.Text,5))>000001&&Value(Right(SampleIDTEXTINPUT.Text,5))<999999&&IsMatch(Left(SampleIDTEXTINPUT.Text,2),"ZZ"),true,Notify("**Format of entered value should like ZZ000001**",NotificationType.Error);Reset(SampleIDTEXTINPUT))

     

    I also need it to recogonise its not at the start and im adding more than one empty sample ID that it remembers the last one and deosnt go back to ZZ000001

     

     

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 320 Most Valuable Professional

#2
11manish Profile Picture

11manish 210

#3
Valantis Profile Picture

Valantis 167

Last 30 days Overall leaderboard