Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Extra records deleting
Message
From
03/02/2009 00:29:58
 
 
To
31/01/2009 19:43:58
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01378618
Message ID:
01378911
Views:
10
>>>I'm using a command button to delete files in a table. The "invoice" to delete is entered into the textbox value. The command works and the file is deleted, except it will mark 1 to 5 additional files with it. The additional files deleted are not related to the text1.value.
>>>
>>>What am I missing?
>>>
>>>In the click command I have the following:
>>>
>>>CLOSE DATABASES
>>>
>>>USE order1
>>>
>>>DELETE from order1;
>>> WHERE thisform.text1.Value = order1.invoice
>>
>>In addition to Borislav's comments:
>>
>>- it may not be a good idea to use object properties in a SQL engine command. For sure, they don't work in UPDATE - SQL: see thread#1264672
>>
>>- normal syntax in SQL is to have
>>
>>... WHERE Column = Value
>>
>>rather than 
>>
>>... WHERE Value = Column
>>
>>I seem to recall some issue with coding the latter way, but I can't find a reference here.
>>
>>As a side note, for maintenance reasons I don't usually put much code in the events/methods of controls. For example, I would normally create a custom form method called, say, DeleteButtonClick().
>>
>>The button's Click() method would contain:
>>=ThisForm.DeleteButtonClick( ThisForm.Text1.Value )
>>
>>and the custom method would be something like:
>>
>>* DeleteButtonClick()
>>LPARAMETERS ;
>>  tcInvoice
>>
>>CLOSE DATABASES ALL
>>
>>USE Order1
>>
>>DELETE FROM Order1 ;
>>  WHERE Order1.Invoice == tcInvoice
>>
>
>
>Thanks Al,
>I had placed thisform.text1.value = ' ' in the forms init to clear the box for the number entry. I believe that was the problem. I'm thinking the textbox was retaining the first record and the new record and deleting both. Removing the command worked.
>
>Do you have a suggestion for clearing the textbox value? Since the textbox control source is the table, the textbox populates with the first record. Leave the control source blank and the delete command doesn't read the entry.
>
>I know that simply typing over it replaces it, but we're using a barcode reader which places the numbers along side any exsisting numbers.

Hmm, I wouldn't use a bound control for a delete like you're doing. I'd use an unbound control, plus the code I outlined above, earlier. That way, whatever you type or barcode into the textbox won't affect a table value until you click on the Delete button.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Reply
Map
View

Click here to load this message in the networking platform