Removing at item using qsrules

I am trying to remove an item that is on the pos store operations screen. I am using the following code and it is giving me a "Type mismatch" error:

Dim objDeleted As Object Set objDeleted Session.Transaction.Entries.Remove(Session.Transaction.Entries(1))

I have also tried to define objDeleted as a transactionentry & transactionentires and take off the "Set" and I get "Object variable or With block variable not set" error. Has anyone been successful in removing an item and if so could you provide the code snippit?

Thanks, Robert

Reply to
rshuptrine
Loading thread data ...

Well, Remove() does not return an object, it returns an enumerated value, so you would be better off with

Dim objDeleted As Variant

-or- Dim objDeleted as long

and getting rid of the Set

You might try this: dim objTestTransEntry as object

ON ERROR RESUME NEXT set objTestTransEntry = Session.Transaction.Entries(1)

if objTestTransEntry is nothing msgbox "No Transaction Entry at ...Entries(1)" end if

ON ERROR GOTO myErrorHandler

Reply to
Glenn Adams [MVP - Retail Mgmt]

Glen, Thanks for the reply. What i am trying to do is to add an item manually then use the remove method to manipulate the quantity and then re-added the item with the manipulated quantity. I am using the add method and it works fine if i add only one item, but when i add a 2nd item the itemlookupcode reverts to the first item added.

Example: Dim objDeleted As Variant objDeleted Session.Transaction.Entries.Remove(Session.Transaction.Entries(strElementNumber))

Dim objAdded As Object Set objAdded = Session.Transaction.Entries.Add(strElementNumber, strItemLookUpCode, mdblFQty, 0, False, 0)

Process = True

I am capturing the ?count? as the element number and it will delete/add the first item fine, but the 2nd time around the itemlookupcode is correct until the add method ? it adds the first itemlookupcode? Any suggestions?

Thanks, Robert

Reply to
rshuptrine

Hi Robert -

Not sure I am following you but wouldn't it be easier to just have the correct quantity entered for the item when you add it the first time? Then you wouldn't need to remove it manipulate the quantity and re-add it with the manipulated quantity.

If you are using the add method:

.Add(ItemID, ItemLookupCode, QuantityPurchased, etc..............)

What is preventing you from assigning the correct quantity to the QuantityPurchased argument and just adding it that way once? Just trying to understand, if I'm not following you please supply some more information.

Thanks, Kevin

"rshuptr> Glen,

Session.Transaction.Entries.Remove(Session.Transaction.Entries(strElementNumber))

Reply to
kskinne

Kevin, We are adding a user form that will allow the user to calculate the quantity based on a formula. In other words the quantity is a user calculated amount and can change based on the unit of measure. So the clerk will scan the item and then if the unit of measure = "a" (for example) then a calculator form shows up - the clerk enters two numbers and the result will be the quantity. That result is then populated in the qty of the add function. But if you don't have the remove function prior to the add funciton then the item is listed twice. Hope that helps. Robert

Reply to
rshuptrine

Hi Robert - I see better what you are saying now. In order to avoid the item being added when you scan it, but still be able to use your code to calculate the quantity and insert it, you could place:

Cancel = True

as the first line of your code to cancel the adding of the item by RMS. Then you can have your code do what it does and then insert the item programmatically. This way you won't have to worry about removing the item.

Or you could make the 'Cancel = True' subject to a condition. Have your code calculate the quantity, and if the calculated quantity is 1 then the code is stopped and the item is added by RMS, but if not, then you do the 'Cancel = True' and insert the item using your code instead. Hope this makes sense

Kevin

"rshuptr> Kevin,

Session.Transaction.Entries.Remove(Session.Transaction.Entries(strElementNumber))

Reply to
kskinne

Kevin, Are you stating to put 'cancel=true' within the function process? I have tried that and getting variable not defined. Remember i am creating this calculator process on the add item hook. Where would i need to place the cancel=true? Thanks, Robert

Reply to
rshuptrine

My apologies, I didn't mean to tell you 'Cancel = True', the correct syntax is 'Process = False', to stop it

hth kevin

"rshuptr> Kevin,

Session.Transaction.Entries.Remove(Session.Transaction.Entries(strElementNumber))

Reply to
kskinne

BeanSmart website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.