1 (edited by CwGhost_1 2017-11-28 10:00:27)

Topic: how to get date from another form date and store it in datetimepicker?

Hi,  how to get date from another form date and store it in datetimepicker?


procedure frmRentalAdd_ComboBox1_OnChange (Sender: string);
begin
 
     frmRentalAdd.DateTimePicker1.DateTime := StrToDate (SQLExecute ('SELECT testdate FROM rentaleqdb WHERE id = ' + (frmRentalAdd.ComboBox1.dbItemID) ) );

end;

http://s019.radikal.ru/i605/1711/be/05b21fe6fb3a.jpg

Re: how to get date from another form date and store it in datetimepicker?

Hello.


procedure frmRentalAdd_ComboBox1_OnChange (Sender: string);
begin
      frmRentalAdd.DateTimePicker1.DateTime := SQLDateTimeToDateTime (SQLExecute ('SELECT testdate FROM rentaleqdb WHERE id = ' + frmRentalAdd.ComboBox1.sqlValue ) );
end;
Dmitry.

Re: how to get date from another form date and store it in datetimepicker?

DriveSoft wrote:

Hello.


procedure frmRentalAdd_ComboBox1_OnChange (Sender: string);
begin
      frmRentalAdd.DateTimePicker1.DateTime := SQLDateTimeToDateTime (SQLExecute ('SELECT testdate FROM rentaleqdb WHERE id = ' + frmRentalAdd.ComboBox1.sqlValue ) );
end;

Same problem occurs again

Re: how to get date from another form date and store it in datetimepicker?

Please attach your project.

Dmitry.

5 (edited by CwGhost_1 2017-11-28 11:28:04)

Re: how to get date from another form date and store it in datetimepicker?

DriveSoft wrote:

Please attach your project.


Attach my project

Post's attachments

Attachment icon testpro.rar 294.96 kb, 965 downloads since 2017-11-28 

Re: how to get date from another form date and store it in datetimepicker?

Something wrong in your logic database.

      SELECT testdate FROM rentaleqdb WHERE id = ' + frmRentalAdd.ComboBox1.sqlValue

frmRentalAdd.ComboBox1.sqlValue contain ID from allequipmentdb database table, but you try to use it for rentaleqdb.id, it's just mistake.


Unfortunately I can't understand what exactly you want to do.

Dmitry.

Re: how to get date from another form date and store it in datetimepicker?

DriveSoft wrote:

Something wrong in your logic database.

      SELECT testdate FROM rentaleqdb WHERE id = ' + frmRentalAdd.ComboBox1.sqlValue

frmRentalAdd.ComboBox1.sqlValue contain ID from allequipmentdb database table, but you try to use it for rentaleqdb.id, it's just mistake.


Unfortunately I can't understand what exactly you want to do.


при выборе оборудования в графе Search model Name, возможно ли автозаполнения граф Date, Model Name и Company name  из базы данных ?

http://s018.radikal.ru/i516/1711/82/0d8167c73b94.jpg

Post's attachments

Attachment icon testpro 2.rar 295.22 kb, 913 downloads since 2017-11-28 

Re: how to get date from another form date and store it in datetimepicker?

Check it out


procedure frmRentalAdd_ComboBox1_OnChange (Sender: string);
var
    s: string;
begin
    s := SQLExecute ('SELECT productdate FROM allequipmentdb WHERE id = ' + frmRentalAdd.ComboBox1.sqlValue );
    if s <> '' then frmRentalAdd.DateTimePicker1.DateTime := SQLDateTimetoDateTime(s) else frmRentalAdd.DateTimePicker1.Checked := False;
end;

But it's not right way.
I can recommend for you to read about database structure (database normalization)
http://myvisualdatabase.com/forum/viewtopic.php?id=986

Dmitry.

Re: how to get date from another form date and store it in datetimepicker?

DriveSoft wrote:

Check it out


procedure frmRentalAdd_ComboBox1_OnChange (Sender: string);
var
    s: string;
begin
    s := SQLExecute ('SELECT productdate FROM allequipmentdb WHERE id = ' + frmRentalAdd.ComboBox1.sqlValue );
    if s <> '' then frmRentalAdd.DateTimePicker1.DateTime := SQLDateTimetoDateTime(s) else frmRentalAdd.DateTimePicker1.Checked := False;
end;

But it's not right way.
I can recommend for you to read about database structure (database normalization)
http://myvisualdatabase.com/forum/viewtopic.php?id=986

Thank you for your help admin, yes it's my mistake