Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Jamie Osborn
  Where is Jamie Osborn?
 Melbourne
 Australia
 Jamie Osborn
 To: munir hossain
  Where is munir hossain?
 dhaka
 Bangladesh
 munir hossain
 Tags
Subject: RE: delete records within range
Thread ID: 16155 Message ID: 16160 # Views: 1 # Ratings: 0
Version: Unknown Category: General VFP Topics
Date: Thursday, October 10, 2002 7:31:49 AM         
   


> Hello
> i WANT TO DELETE RECORDS FROM A TABLE BETWEEN TWO DATE RANGE( LIKE 09/12/01 TO 10/12/01)
> AND ADD A CONDITION LIKE PEOPLE WHO LIVE IN "CA" AND I WANT TO INPUT THOSE VALUES
> (tWO DATES AND PLACE NAME = "CA" ) BY FORM(FORM HAS THREE TEXT BOXS AND ONE COMMAND BUTTON ).
>
> IF I WANT TO PUT option group control IN THAT FORM AND WANT TO GIVE USER a CHOICE BETWEEN
> DELETE ALL RECORDS WITHIN A DATE RANGE OR DELETE ALL RECORDS FOR WITHIN A DATE RANGE and SELECTED PLACENAME LIKE "CA".
> WHAT CODE I SHOULD WRITE AND WHERE?
> (mY FORM HAS TWO TEXT BOX FOR DATE RANGE,ONE TEXT BOX FOR PLACENAME, ONE OPTION CONTROL,ONE
> COMMAND BUTTON.)

Crikey - do you want us to make you dinner as well ? :)

OK -

I would put this in the Init() of the textboxes to ensure they have a date value:
this.value = {}  && or whatever you want


I would use a combobox to hold the possible state choices:
STYLE = 2
ROWSOURCETYPE = 3
ROWSOURCE = "SELECT DISTINCT State FROM MyTable ORDER BY state INTO CURSOR r_state"
ENABLED = .F.

In the destroy of the combobox I would put:
USE IN r_State

In the interactivechange() of the optiongroup I would put :
thisform.cboState.Enabled = (this.Value = 2) && Only enable state choice if I want it

I would add a form method - Something like Delete() and in that method put :
LOCAL ldFrom,ldTo,lcFor

*-- Initialise local variables (always a good idea)
STORE thisform.txtFromDate.Value TO ldFrom
STORE thisform.txtToDate.Value TO ldTo
STORE "" TO lcFor

*-- If we are including state criteria then fill the variable to be used in the DELETE statement
IF thisform.opgCriteria.Value = 2
  lcFor = [AND MyTable.State = "] + thisform.cboState.Value + ["]
ENDIF

DELETE ALL FOR BETWEEN(MyDate,ldFrom,ldTo) ;
               &lcFor IN MyTable
 


And then call that method in my Command Button Click() method
ie. thisform.Delete()

I hope I remembered everthing !!!

Cheers,
Jamie
jamie.osborn@foxite.com


ENTIRE THREAD

delete records within range Posted by munir hossain @ 10/10/2002 6:49:17 AM
RE: delete records within range Posted by Jamie Osborn @ 10/10/2002 7:28:52 AM
RE: delete records within range Posted by Jamie Osborn @ 10/10/2002 7:31:49 AM