Topic: Update Database column between two dates

Hi Everybody

I'm a beginner in scripting and attempted to find the answer in the form but might not have had the vocabulary to getting about finding what I wanted.

I am working with a waiting list for clients such that I need to update the whole database of how many days people have been waiting.

An initial date has been entered when a request was made, but unless I enter in each file manually and save the database will not update how many days the client is waiting.

I am use this script when I enter the form (Onshow) and when I click the Save button to update the table.

VAR
    // Calculate number of days client on waiting list.
    i : integer;
    iDays: integer;
    start, stop: integer;

Begin    // Calculate the number of days client is on waiting list.
    if ClientCreate.DateAssigned.Checked = false  then
         begin
            iDays := 0;
            start := Trunc (ClientCreate.DateDiscipline.date);
            stop := Trunc (date);
                 for i := start to stop do
                         Inc(iDays);
                Begin
                      ClientCreate.ClientDaysWaiting.Value := iDays;         
                end;
         end;


I would like to have a script that upon entering the main menu, the table for all the clients is updated automatically.

Any help would be greatly appreicated.

Tks.
Jeff

Re: Update Database column between two dates

Hi Jeff,
Can you not achieve what you need with a calculated field (see attached)?
Because calculated fields are not stored but calculated 'on the fly', then the problem with having to constantly update all the 'waiting days' is removed.
Regards,
Derek.

Post's attachments

Attachment icon assigned clients.zip 443.29 kb, 95 downloads since 2024-10-08