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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code - Error 33 when deleting a row by hand 1

Status
Not open for further replies.

rleiman

Programmer
May 3, 2006
258
US
Hi Everyone,

Can you check out this code and tell me what else I need to add to it so I don't get the error 33?

The key values are already initialized before this code was called from a button.

The SalesItemsList.ResetFromFile() shows that the data has dissapeared but I get the error when I exit the app or try to add another sales header.

Thanks.
Emad

Code:
Get (SalesHeader, SalHed:KeySalesNumber)

Delete (SalesHeader)

Display

SalesItemsList.ResetFromFile()
 
Hi Emad,

Always check for errors.

Get (SalesHeader, SalHed:KeySalesNumber)
IF ERRORCODE()
...
ELSE
Delete (SalesHeader)
IF ERRORCODE()
...
ELSE
END
END

And use ResetSort(True). ResetFromFile possibly tries to refresh from current record which has been deleted.

Regards
 
Hi Shankarj,

Thanks for the code.

I did some more investigation and found that the row was not actually in the database. I had a pending row in my edit in place browse that line gets written to the database when I close the window.

Can you tell me what code to use to put in my "CloseWindow" embed to stop it from writing to the database?

Truly,
Emad


 
Hi ShankarJ,

Here is the code I tried to use in the "CloseWindow" embed:

Code:
Erase

GlobalResponse = RequestCancelled

! Redisplay the browse.
!----------------------
SalesItemsList.ResetFromFile()

! Close the application.
!-----------------------
GLO:CleanCloseDown = True
NOTIFY(NOTIFY:CloseDown,GLO:CleanCloseDownMainThread)

Truly,
Emad
 
Hi Emad,

Check the EIP properties of the Browse. You can set the default action NOT to save automatically.

Regards
 
Hi ShankarJ,

I set the "loose focus" option of save to "Never" but it still saved the row. I also placed code to delete the rows in the "CloseWindow" embed but it seems to ignore that code and place them back and save them prior to exiting the app.

Is there an event I can post that will tell the app not to save anything that is pending? If yes, please let me know what coding to use.

Thanks for your effort.

Truly,
Emad
 
Hi Emad,

Have you tried your code in WindowManager.Kill() before the files are closed? This is more or less the final embeddable method.

Regards
 
Hi ShankarJ,

It did not work but here is the code I used in that embed.

Code:
! Cancel the not needed 0 order.
!-------------------------------

SalHed:CustNumber = 0
Get (SalesHeader, SalHed:KeyCustNumber)

If Not ErrorCode() |
Then
   Delete (SalesHeader)
Else
   Message (ErrorCode())
End

! Close the application.
!-----------------------
GLO:CleanCloseDown = True
NOTIFY(NOTIFY:CloseDown,GLO:CleanCloseDownMainThread)

What I have been trying to do is remore the sales header that is created with a customer number 0 but the code returns an error code 35 now.

I think the problem now is in the get statement.

Thanks,
Emad
 
Hi Emad,

I possibly did not read carefully the previous time but I think the reason is as follows:

- You are unable to retrieve by the KEY because the key has the Exclude Nulls (OPT attribute). So, a record with a CustNumber value of ZERO does not create a KEY entry.

- You can easily remove ZERO by scanning from the BOTTOM of the FILE in FILE order as the last added record should logically placed at the bottom of the file i.e.

CLEAR(SalHed:Record,1)
SET(SalesHeader)
LOOP 10 TIMES ! scan last 10 records
PREVIOUS(SalesHeader)

IF ERRORCODE() THEN BREAK.
IF SalHed:CustNumber = 0
DELETE (SalesHeader)
IF ERRORCODE()
...
END
BREAK
END
END

If the above does NOT work, use another key in SalesHeader which can help you retrieve ZERO CustNumber records.

- You can place this in the KILL method as a sort of cleanup before exiting.

Regards
 
Hi ShankarJ,

You hit the nail on it's head!

I unchecked the "Exclude Null" in the data dictionary and everything worked.

Thanks for taking the time to help me on this one.

Truly,
Emad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top