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

HELP DELETING RECORDS

Status
Not open for further replies.

lashwarj

IS-IT--Management
Nov 1, 2000
1,067
US
I have a list box with a bound colum and a field on a form with another value.

In the click event of the list box I have it setting a another text box to the value of the bound colum, this works.

In the double click I have the following piece of code, but it deletes all namelk_ID in the system.

The namelk_ID may be assigned to 100 other records but when you dblclick it removes them from all, as if the code below does not see the and, but both values are there.

Message_Title = 'Confirm'
Message_Text = 'Are you sure you want to delete this name and name type?'
Dialog_Type = 4 + 32 + 0
nAnswer = MESSAGEBOX(Message_Text, Dialog_Type, Message_Title)
DO CASE
CASE nAnswer = 6
namelk_ID = VAL(Thisform.delete_name.value)
Vpm_id = Thisform.approval_id.value

SELECT PM_LK_PERMIT_NAME
DELETE FOR ((PM_LK_PERMIT_NAME.Key_id = Thisform.approval_id.value)AND (PM_LK_PERMIT_NAME.na_id = namelk_ID)) IN PM_LK_PERMIT_NAME
 
nope still deletes all out , i am totally confused, if you run the debugger it shows the values in the code you are specifying, but still deletes all namelk_id values the same, as if it doesnt care about the AND critiria
 
Hi Lashwarj,

I'd use code like this instead:
Code:
Message_Title = 'Confirm'
Message_Text = 'Are you sure you want to delete this name and name type?'
Dialog_Type = 4 + 32 + 0
namelk_ID = VAL(Thisform.delete_name.value)
Vpm_id = Thisform.approval_id.value
If MESSAGEBOX(Message_Text, Dialog_Type, Message_Title) = 6
  SELECT PM_LK_PERMIT_NAME
  DELETE FOR (Key_id == Vpm_id) .AND. (na_id == namelk_ID)
Endif

As you have selected the table explicitly and saved the values.

It's possible that the activate event of your form is changing the contents of the two fields (approval_id and/or delete_name) on returning from the messagebox - so take the values before doing the message!

Good luck


Regards

Griff
Keep [Smile]ing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top