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!

Clearing fields of "Date" type in a database

Status
Not open for further replies.

fitzgerald

Technical User
Nov 25, 2002
8
GB
Nearly at the end of my program but there's one problem that I cannot get around:

My database is done in Paradox7.

I have a DBGrid that displays records contained within a database. You can select individual records within the DBGrid. The records have a "ReturnDate" field, which is of Type: Date, and I want the program to CLEAR this field (so there is NO information remaining in it) of the selected record when a button is pressed.

Here's the code I have so far:

procedure TForm3.Button6Click(Sender: TObject);
begin

Table1.Edit;
Table1.FieldValues['RentedVideo']:='';
Table1.FieldValues['ReturnDate']:='';
Table1.Post;
Table1.Refresh;
end;


I have got some code that clears the other field in the database (This one is called "RentedVideo" and is Type: Alphanumeric) and this works fine.

Problem is, when it tries to clear the "ReturnDate" field, I get the error: "Invalid Variant Type Conversion". I'm assuming that this is because the field is a Date type, because the Alphanumeric field clears fine.

Any help will be greatly appreciated as always :)
 
Problem is, when it tries to clear the "ReturnDate" field, I get the error: "Invalid Variant Type Conversion". I'm assuming that this is because the field is a Date type..

yes I also think so.. Date type have to have a date value.. it can not be empty...

maybe this will work not sure...
Table1.FieldValues['ReturnDate']:= NULL; //give field value NULL
//you have to add Variants in your uses clause.

if not I would assign the ReturnDate field as string.

If you need to convert this to date you could use
StrToDate - vica versa - DateToStr

mha

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top