Showing results for 
Search instead for 
Did you mean: 
Post Patron
Post Patron

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



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



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







Super User
Super User


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

@timl wrote:


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




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




Which gets it from




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..



Super User
Super User


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


Super User
Super User


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.

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)



Super User
Super User


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?

Its just a simple collect code,

Collect(colTEST, {Title:"Title", SampleID:SampleIDTEXTINPUT.Text})

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)



Helpful resources

Power Apps News & Annoucements carousel

Power Apps News & Announcements

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

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

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 (4,860)