Automatically update Matrix when Checkbox clicked

Hello, and thanks for reading.

I have a form with a Matrix object named “Titles”

Above the Matrix object, there’s a checkbox linked to a field called “Prioritize”

Clicking the checkbox correctly updates the data sheet, but the matrix doesn’t update unless I switch to graphics mode and then back to data mode.

I found this suggestion here on the forum, and have added it to the checkbox procedure, but it’s still not refreshing:

ObjectAction "Titles","redraw","all"

Also tried this, though I’m not sure I’m using it right:

    ObjectAction "Titles","redraw","all"
    execute arrayfilter(dbinfo("fields",""),cr(),|||sandwich(chevronquoted(import())+"=",fieldformula("",import()),"")|||)

I’m sure I’m missing something. Any help appreciated. Have a great day!
Biagio

Here is an old hack that invisibly selects the next record above or below the current selection and then back again which will update a matrix synced to the datasheet. Add this to your checkbox procedure.

noshow
if info("bof")
    downrecord
    uprecord
else
    uprecord
    downrecord
endif
endnoshow
showpage

Not sure if this will help in your situation but worth trying.

Thanks, @gary. Tried the example both solo and with the other code, but looks like it’s the same behavior. I’ve now realized that clicking any other cell also updates the matrix, and I’m guessing that’s what the code you shared is “imitating” - just looks like it’s not working here.

But I’ll keep this cool trick in my back pocket - I’m sure it will come in handy. Thanks again.

Best,
Biagio

There is an undocumented statement used by the Refresh tool bar item in graphics mode called refreshmatrixes. Jim noted in a previous post that this should probably work in data mode as well. It supposedly deletes all the matrix objects on the current form and redraws them new. I have not tried this so I can’t comment further on how fast or safe it might be. :expressionless:

Thank you, @gary. Tried it but no success. Also searched the forum and found the thread you referenced, tried a few suggestions from there, but I can’t seem to get it working. BTW - I realize I may be barking up the wrong tree if I’m using the matrix in an unintended fashion. But as always, I appreciate the guidance. Have a great night!

All the best,
Biagio

I think that you need to make a variable which contains the text in the matrix, and then update that variable. Showvariables will update it.

1 Like

Thanks, Bruce. Definitely need to brush up on variables in PX, appreciate the direction and I’ll get on it.

Thanks everyone for the tips. With some experimentation I figured out that adding this to the procedure pane of the checkbox did the trick:

uprecord 
downrecord

Thanks to @gary for the idea to try “bouncing” around records. There’s a tiny flash now when the checkbox is clicked, but the field updates correctly and can be toggled on and off.

If anyone has any other ideas I’d love to hear them, but this is working good enough for me right now. Thanks everyone!

All the best,
Biagio

Well Biagio, the code I gave you previously is what I expected you to put where you just put the abbreviated code you just listed. My code added a couple of features you might want to incorporate. The first is to add the noshow/endnoshow/showpage to keep the datasheet from flashing at all. The second feature is to test to see if you are currently at the top record of the datasheet so you would have to go down a record and then back up. In all other cases you would go up a record and then back down. In you simple code nothing will happen if you are currently on the first or top record.

Obviously the choice is yours.

1 Like

I replied to this thread twice from my email, but that no longer seems to be working so I am replying from the discussion forum.

This is very crude, but it can work to redraw a matrix or maybe it was a text list (worth a try). Put this in the procedure pane of your checkbox or call a procedure with the code at the end.

formtographicsmode
formtodatamode

You could also try this if the page blinks:

noshow
formtographicsmode
formtodatamode
showpage

Also, I believe in Gary’s post,
if info(“bof”)
downrecord
uprecordName

uprecordName is a typo. It should be uprecord. Is that right Gary?

1 Like

Error indeed - don’t have any idea how that got included and I hadn’t noticed myself. I have edited the original post to remove it. Thanks for catching that, it was probably the reason Biagio couldn’t get it to work initially.:flushed:

1 Like

Thanks for the clarification @gary, I had put uprecordName in there, so that was the holdup. I’ve tried the code again changing it to “uprecord” and it works perfectly, no flashing, feels totally seamless. Thanks!

Thanks @JeffK - tried this and it worked with a tiny “glitch” but was totally acceptable (if the inspector was open it would flash in and out), but your catch on the uprecordName was really helpful. I’m still too new to have realized it was a typo. Using that approach has now proved seamless. Thanks for the guidance, and for trying two emails first :+1:

All the best,
Biagio