Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BULK delete Sales orders 1

Status
Not open for further replies.

johnny45

Technical User
Nov 8, 2006
136
CA
I havea bout 100 sales orders to delete for a particular customer with a particular item....Is it possible to bulk delete thes Sales orders or must it be done one by one?
 
Dim mDBLinkCmpRW As AccpacCOMAPI.AccpacDBLink
Set mDBLinkCmpRW = OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READWRITE)
Dim OEORD1header As AccpacCOMAPI.AccpacView
mDBLinkCmpRW.OpenView "OE0520", OEORD1header
Dim OEORD1detail1 As AccpacCOMAPI.AccpacView
mDBLinkCmpRW.OpenView "OE0500", OEORD1detail1
Dim OEORD1detail2 As AccpacCOMAPI.AccpacView
mDBLinkCmpRW.OpenView "OE0740", OEORD1detail2
Dim OEORD1detail3 As AccpacCOMAPI.AccpacView
mDBLinkCmpRW.OpenView "OE0180", OEORD1detail3
Dim OEORD1detail4 As AccpacCOMAPI.AccpacView
mDBLinkCmpRW.OpenView "OE0680", OEORD1detail4
Dim OEORD1detail5 As AccpacCOMAPI.AccpacView
mDBLinkCmpRW.OpenView "OE0526", OEORD1detail5
Dim OEORD1detail6 As AccpacCOMAPI.AccpacView
mDBLinkCmpRW.OpenView "OE0522", OEORD1detail6
Dim OEORD1detail7 As AccpacCOMAPI.AccpacView
mDBLinkCmpRW.OpenView "OE0501", OEORD1detail7
Dim OEORD1detail8 As AccpacCOMAPI.AccpacView
mDBLinkCmpRW.OpenView "OE0502", OEORD1detail8
Dim OEORD1detail9 As AccpacCOMAPI.AccpacView
mDBLinkCmpRW.OpenView "OE0504", OEORD1detail9
Dim OEORD1detail10 As AccpacCOMAPI.AccpacView
mDBLinkCmpRW.OpenView "OE0503", OEORD1detail10

OEORD1header.Compose Array(OEORD1detail1, OEORD1detail4, OEORD1detail3, OEORD1detail2, OEORD1detail5, OEORD1detail6)
OEORD1detail1.Compose Array(OEORD1header, OEORD1detail7, OEORD1detail10, OEORD1detail8)
OEORD1detail2.Compose Array(OEORD1header)
OEORD1detail3.Compose Array(OEORD1header, OEORD1detail1)
OEORD1detail4.Compose Array(OEORD1header, OEORD1detail1)
OEORD1detail5.Compose Array(OEORD1header)
OEORD1detail6.Compose Array(OEORD1header)
OEORD1detail7.Compose Array(OEORD1detail1)
OEORD1detail8.Compose Array(OEORD1detail1, OEORD1detail9)
OEORD1detail9.Compose Array(OEORD1detail8)
OEORD1detail10.Compose Array(OEORD1detail1)


OEORD1header.Browse "{Insert your criteria here}", True

Do While OEORD1header.Fetch
OEORD1header.Delete
Loop
 
WOW thanks Tuba,

How would I put
customer No.=1234
Item # =321
so that the macro deletes only POS from customer 1234 with this item 321 on it ?
 
This should work:

OEORD1header.Order = 2 ' Customer number order
OEORD1header.Browse "CUSTOMER = 1234 AND COMPLETE < 3", True

Do While OEORD1header.Fetch
OEORD1Detail1.Browse "ITEM = 321", True
If OEORD1Detail1.Fetch then
OEORD1header.Delete
end if
Loop

 
Why did this not work ?
Code:
'For i = 75050 To 75085
Do While OEORD1header.Fetch
    OEORD1detail1.Browse "ITEM =" & i, True
    If OEORD1detail1.Fetch Then
         OEORD1header.Delete
    End If
Loop

Do While OEORD1header.Fetch
    OEORD1header.Delete
Loop
'Next
 
You have 2 loops and they are not nested.
The first loop is on the details, and you most likely do not have a header record open, so nothing will be found in the first loop.
The second loop is going to read every order you have, and potentially delete every order.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top