Board index » delphi » Help: Invalid Variant Type Conversion Error

Help: Invalid Variant Type Conversion Error

Environment: Windows 2000, Access 2000, Delphi 5, ADOExpress. Delphi and
ADOExpress each have the Updates.

I have an access table with a text field called "NickName".  If I edit
that field with Access and erase the value I get the error "Invalid
Variant Type Conversion.  If I put a value in the field and erase it
with my program, I have no problems. It is blowing up in the following
lines:

var
 sNickName: String;
begin
  inherited;
  sNickName := tbData.FieldByName('NickName').Value;

What am I doing wrong? In general, how does Access store "empty" text
fields?

Thanks.

Luke Miller
ResCorSoft

 

Re:Help: Invalid Variant Type Conversion Error


In <39220D39.8FFA4...@onebox.com>, Luke Miller hastily scribbled:

Quote
> Environment: Windows 2000, Access 2000, Delphi 5, ADOExpress. Delphi and
> ADOExpress each have the Updates.

> I have an access table with a text field called "NickName".  If I edit
> that field with Access and erase the value I get the error "Invalid
> Variant Type Conversion.  If I put a value in the field and erase it
> with my program, I have no problems. It is blowing up in the following
> lines:

> var
>  sNickName: String;
> begin
>   inherited;
>   sNickName := tbData.FieldByName('NickName').Value;

> What am I doing wrong? In general, how does Access store "empty" text
> fields?

You probably need to test for a null value:

var
    X: Variant;

    X := tbData.FieldByName('NickName').Value;      //  No conversion in this line

//  Implicit conversion to string in this line
    if VarIsNull(X) then sNickName = '' else sNickName := X;

Roger Morton
roger.mor...@dial.pipex.com

Re:Help: Invalid Variant Type Conversion Error


Var
 sNickName: String;
begin
  inherited;
  sNickName := tbData.FieldByName('NickName').String; //note the
differece here

In article <39220D39.8FFA4...@onebox.com>, Luke Miller
<lukemil...@onebox.com> writes

Quote
>Environment: Windows 2000, Access 2000, Delphi 5, ADOExpress. Delphi and
>ADOExpress each have the Updates.

>I have an access table with a text field called "NickName".  If I edit
>that field with Access and erase the value I get the error "Invalid
>Variant Type Conversion.  If I put a value in the field and erase it
>with my program, I have no problems. It is blowing up in the following
>lines:

>var
> sNickName: String;
>begin
>  inherited;
>  sNickName := tbData.FieldByName('NickName').Value;

>What am I doing wrong? In general, how does Access store "empty" text
>fields?

>Thanks.

>Luke Miller
>ResCorSoft

--
Arnold Johnson

Re:Help: Invalid Variant Type Conversion Error


Quote
> tbData.FieldByName('NickName').String;

What's this Arnold? Is it some new implementation of the
TField object? Because the one I know of doesn't have
a property named "String". Maybe "AsString"?  ;-)

--
V. Nazarov
IT Manager, Sofia Cable

Quote
"Arnold Johnson" <Arno...@win-pro.demon.co.uk> wrote in message

news:7+7VvHA9ilI5EwJz@win-pro.demon.co.uk...
Quote

> Var
>  sNickName: String;
> begin
>   inherited;
>   sNickName := tbData.FieldByName('NickName').String; file://note the
> differece here

> In article <39220D39.8FFA4...@onebox.com>, Luke Miller
> <lukemil...@onebox.com> writes
> >Environment: Windows 2000, Access 2000, Delphi 5, ADOExpress. Delphi and
> >ADOExpress each have the Updates.

> >I have an access table with a text field called "NickName".  If I edit
> >that field with Access and erase the value I get the error "Invalid
> >Variant Type Conversion.  If I put a value in the field and erase it
> >with my program, I have no problems. It is blowing up in the following
> >lines:

> >var
> > sNickName: String;
> >begin
> >  inherited;
> >  sNickName := tbData.FieldByName('NickName').Value;

> >What am I doing wrong? In general, how does Access store "empty" text
> >fields?

> >Thanks.

> >Luke Miller
> >ResCorSoft

> --
> Arnold Johnson

Re:Help: Invalid Variant Type Conversion Error


My mistake it is supposed to be .AsString. Thanks for the correction.

In article <392297e7@dnews>, Vassil Nazarov <s...@bulnet.bg> writes

Quote
>> tbData.FieldByName('NickName').String;

>What's this Arnold? Is it some new implementation of the
>TField object? Because the one I know of doesn't have
>a property named "String". Maybe "AsString"?  ;-)

>--
>V. Nazarov
>IT Manager, Sofia Cable

>"Arnold Johnson" <Arno...@win-pro.demon.co.uk> wrote in message
>news:7+7VvHA9ilI5EwJz@win-pro.demon.co.uk...

>> Var
>>  sNickName: String;
>> begin
>>   inherited;
>>   sNickName := tbData.FieldByName('NickName').String; file://note the
>> differece here

>> In article <39220D39.8FFA4...@onebox.com>, Luke Miller
>> <lukemil...@onebox.com> writes
>> >Environment: Windows 2000, Access 2000, Delphi 5, ADOExpress. Delphi and
>> >ADOExpress each have the Updates.

>> >I have an access table with a text field called "NickName".  If I edit
>> >that field with Access and erase the value I get the error "Invalid
>> >Variant Type Conversion.  If I put a value in the field and erase it
>> >with my program, I have no problems. It is blowing up in the following
>> >lines:

>> >var
>> > sNickName: String;
>> >begin
>> >  inherited;
>> >  sNickName := tbData.FieldByName('NickName').Value;

>> >What am I doing wrong? In general, how does Access store "empty" text
>> >fields?

>> >Thanks.

>> >Luke Miller
>> >ResCorSoft

>> --
>> Arnold Johnson

--
Arnold Johnson

Other Threads