We help IT Professionals succeed at work.

Invalid variant type conversion

aussie_guy_nik
on
Gettin error "Invalid variant type conversion"
when trying to run this line on a form which has a date picker.

 "modAssignment2.tblTender.Append;"

if i remove date picker field from the form, then it works fine.
Comment
Watch Question

CERTIFIED EXPERT

Commented:
Is the datetimepicker a descendant of the original TDateTimePicker or are you using "the real thing"?

If you have created your own component from it, I believe the problem might be with the component, not your actual code.

Another possibility is code related to the Table's events (such as OnNewRecord), or the DataSet's events.

Please post more code so we can figure out exactly what is causing the error.

Yours,

Alex
CERTIFIED EXPERT
Top Expert 2004
Commented:
well, guessing also,
that you want assign a null-value to the datetime-picker.

you should evaluate the field for null before assiging like

if dataset.fieldbyname('adatefield').IsNull then
  //your empty datevalue
else
  datetimepicker1.date := dataset.fieldbyname('adatefield').AsDateTime;

meikl ;-)

Commented:
hi!

try this:

dataset.fieldvalues['fieldname'] := datetimepicker1.date.

provided that the fieldname is of type date.

regards!

candz

Explore More ContentExplore courses, solutions, and other research materials related to this topic.