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

problems with my delete button

Status
Not open for further replies.

Octagon6

Programmer
Mar 18, 2003
18
US
I'm still a little confused on my delete button. Instead of it deleting the current record, it deletes all the records in the table. Can you review my code and tell me what I need to change? thanks in advance.

lcchoice = ""
lcchoice = MESSAGEBOX("Are you sure you want to delete this record?",4,"Warning")

IF lcchoice = 6 then
SET DELETED ON
USE oms_requests
DELETE FOR request_no = ALLTRIM(thisform.txtrequest_num.Value)
PACK
MESSAGEBOX("Record Deleted",0,"FYI")
GO bottom
ELSE
ENDIF
 
Well based on your code I am assuming that Request_no is a character field and you may try changing:

request_no = ALLTRIM(thisform.txtrequest_num.Value)

TO

request_no == ALLTRIM(thisform.txtrequest_num.Value)



Slighthaze = NULL
 
Octagon6

Why use a FOR condition? You are already on the record to be deleted.

Code:
SET DELETED ON
lcchoice = ""
lcchoice = MESSAGEBOX("Are you sure you want to delete this record?",4,"Warning")
IF lcchoice = 6 
    USE oms_requests
    DELETE 
    PACK ** not advisable in a network situation
    LOCATE
ENDIF




Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
DELETE FOR will delete any record matching the criteria, which in this case could be all of them since an empty txtrequest_num could result in a non-exact match of all records.
You should probably find the record you want deleted first, then delete it.

LOCATE FOR request_no == ALLTRIM(thisform.txtrequest_num.Value)
Code:
IF FOUND()
   DELETE
ENDIF

Dave S.
[cheers]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top