My experience with this is that you have to FIRST pick up the item before you can do it like that. If you don't, this error page shows up. In the case of my Pill Shop, I'd set it up so that AFTER you buy the pill, (pick the item up) whenever you used up the pill you bought, you can always go back to the store to buy it again, as many times as you want.
I just put this code in the previous button of the item page:
$ITEMSTATE1 := 1
$ITEMUSED1 := 0
BUT this ONLY works after you pick up the item, not before. It's just an unsolved bug I guess. *Shrugs.