Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Removing items in a listbox with a SQL source
Message
 
To
26/09/2003 11:48:27
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00832474
Message ID:
00832775
Views:
17
>>Hi all,
>>
>>I'm building a work order form that has a listbox on a pageframe that is populated with a SQL statement so that the items related to that order are the items in the list box. The user needs to be able to remove items from the order. I'm having problems getting this to work. This code is in the click event of cmdRemoveItem.
>>
>>LOCAL cSelectedItem
>>*** remove one item from this order
>>cSelectedItem = thisform.pgfPuDlvDetails.pagstop1.lstOrderItems.Selected
>>IF MESSAGEBOX("Are you sure you want to remove this item?", 292,;
>>	    "Please confirm removing this item") = 6
>>    IF cSelectedItem
>>         thisform.pgfPuDlvDetails.pagstop1.lstOrderItems.RemoveItem
>>    ENDIF
>>ENDIF
>>thisform.Refresh
>>DODEFAULT()
>>
>>I've tried variations on this and can't seem to get it to work. After it does work I need to update the underlying table and run the query again so the form is refreshed with the revised data. Where am I missing the point?
>>Using VFP8 with Codemine7.1 on W2Ksp4
>>TIA
>
>Matthew,
>As I understand modeling this with testdata.dbc you'd remove the items from orditems ? ie :
>Assuming there is an txtOrderID on form with an initial value=0
>
>
>* txtOrderID.Valid
>thisform.lstmyList.Requery()
>
>* Listbox.init
>With This
>  .RowSourceType = 3 && SQL
>  .RowSource = ;
>    'Select pr.prod_name, oi.Quantity, oi.unit_price, '+;
>    '  oi.line_no, o.cust_id, o.order_id '+;
>    '  from orders o '+;
>    '  inner Join orditems oi On o.order_id = oi.order_id '+;
>    '  inner Join products pr On pr.product_ID = oi.product_ID '+;
>    '  where Val(o.order_id) = Thisform.txtOrderID.Value '+;
>    '  order By oi.line_no '+;
>    '  into Cursor crsOItems'
>  .ColumnCount = 4
>  .ColumnWidths = "150,100,100,50"
>  .MultiSelect = .T.
>Endwith
>
>* command button click
>*Confirm deletion - assuming no buffer for simplicity
>With Thisform.lstMyList
>  Select crsOItems
>  Scan For .Selected(Recno())
>    Delete From ordItems ;
>      where order_id = crsOItems.order_id And ;
>            line_no = crsOItems.line_no
>  Endscan
>  .ListIndex=0
>  .Requery
>Endwith
>
>PS: You could do this easier with Foxyclasses' MultiSelectGrid and Moverlist classes.
>Cetin

Thanks, This gives me more to think about. One of the other things that happens is that the items on an order belong to a customer. They are stored in the warehouse. As items are added to a work order their status is updated to 'assigned' so they cannot be added to another order, or added again to the same order. If I remove an item from the order not only do I need to update the order_items table to show that it is no longer on the item, but I also need to change the status in the items table to place the item 'in warehouse'.

Using the code you suggest, am I still limited to the total number of characters in the rowsource property? It seems to be 255 characters using the property page.
Opportunity is missed by most people beacuse it is dressed in overalls, and looks like work --- Thomas Edison
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform