1 (edited by g0dmenuelz 2019-05-07 13:33:04)

Topic: How to turn cell into green with a specific condition?

Hi guys, I would just like to ask how to turn the cell red if the date is 5 days after the document is received but it would overwrite it and turn green if the status on the dropdown box says  "for printing, For dissemination to concerned offices and filed".

I was able to find the same issue with this one.

http://myvisualdatabase.com/forum/viewtopic.php?id=5283

I tried to use the same script and only able to turn it to green but cannot turn overdue documents to red.

also I'd like to thank Derek for helping me with this project.

Any help is appreciated.

Thanks guys.

Post's attachments

Attachment icon paper routing system.rar 1.55 mb, 297 downloads since 2019-05-07 

Re: How to turn cell into green with a specific condition?

Hi,
I think the problem might be the 'datein' field, originally defined as 'date/time' - when you change it to 'date' the code works fine and overdue items are coloured red.
Also, remember that when you are writing scripts that reference specific columns, columns (and rows) start at 0, not 1.  So you needed to change your [2,i].color to [1,i].color etc etc because you moved the 'datetin' column.  Also, your 'hotspot' columns needed to change because you'd added a new column.
You could also  colour the days overdue column - that way you can easily see whether an item was late processed irrespective of whether it has now been filed, printed or 'for dissemination'.  Just a thought.
Derek.

Post's attachments

Attachment icon paper routing system.zip 1.59 mb, 294 downloads since 2019-05-07 

3 (edited by tcoton 2019-05-07 16:09:24)

Re: How to turn cell into green with a specific condition?

Fixed with this:

procedure Form1_TableGrid1_OnChange (Sender: string);
var
   i,c: integer;
   s: string;
begin
     c := Form1.TableGrid1.RowCount - 1;
     for i := 0 to c do
     begin
         s := Form1.TableGrid1.Cells[1,i];   // Edit Tcoton: count the column from 0, it was checking the column after the received date
        // if ValidDate(s) then     -- Edit Tcoton, does not work if active
             if (StrToDateTime(s) + 5) < now() then Form1.TableGrid1.Cell[12,i].Color := clRed; //Edit Tcoton: Use StrDateTime instead of StrToDate and add () after now
             if form1.TableGrid1.cells[12,i] = 'Filed' then Form1.TableGrid1.Cell[12,i].Color := clgreen;
     end;
end;

4 (edited by g0dmenuelz 2019-05-08 12:12:18)

Re: How to turn cell into green with a specific condition?

@Ttcoton  Thanks for the detailed explanation on the script.

Thanks again Derek. Also The "hotspot" feature is really awesome.  But it seems not to be working if the command is set to linkto instead of copyto.

I need the file to be save inside the Attachments folder with the MVD folder on the shared folder for our lan (5 people), so that when adding the attachments the other person can also see it on their end. I tried to use the script on the Attachment1 and Attachment2 but to no avail that is why I am using the old

Form1.DBImage1.loadfromdatabase('docmaster','attachment1', Form1.TableGrid1.dbitemid);

and a button.

Can your hotspot feature work with the "linkto" option? It will be really nice.

by the way if I share the sqllite.db on the LAN, the database get shared but the attachments aren't seen. Should I just create a shortcut of the app itself on the shared folder and share that the desktop of the users?

Sorry for asking a lot of questions. smile

If others have ideas, please don't hesitate to share it as well. Thanks guys!

Re: How to turn cell into green with a specific condition?

Hi,
The 'hotspots' should work irrespective of whether your document locations point to the original location or point to the 'copyto' location.
It's generally not such a good idea to use 'storefile' for your documents, photos etc as the size of your application can quickly get very large.  I normally select 'linkfile' and choose a 'copyto' location so that all the documents which may have come from any number of places all end up saved to a single location;  an 'attachments' folder within the MVD app folder is fine but it could be any location (specific machine, LAN or WAN).
If you want your attachments to be seen by all users, then the folder they are saved in needs to be shared;  just sharing the sqlite.db is not enough when you use 'linkfile' for your attachments - the database points the users to the linked file but if that location isn't shared, they won't be able to see anything (if you were to use 'storefile' this wouldn't be an issue because the actual attachment is part of the database, not just a pointer).
I've changed your app so that it now hotspots on Column 2 (Doc Title), Column 7 (Attachment 1), Column12 (to see the Document Flow History) and Column 13 (Attachment 2 (Signed Doc).  It's a useful trick when using multiple hotspots to just put an '*' in the Column Heading in the tablegrid to remind users about the feature.
A couple of other things.  Your Attachment2 wasn't working because you weren't saving it (Form2 Button4).  Also, you might want to define Attachment 1 and Attachment 2 in your database as 'file' rather than 'image';  as it is, they can't be .txt, .doc etc file types (I just find using 'file' is less restrictive, but it might not be an issue for you).
Hopefully, it's all working okay now.
Derek.

Post's attachments

Attachment icon paper routing system.zip 567.8 kb, 336 downloads since 2019-05-08 

Re: How to turn cell into green with a specific condition?

Yes everything is working fine now.

Thanks for sharing your expertise Derek.

I have learned a lot.

Re: How to turn cell into green with a specific condition?

I have learned some neat tricks as well!! smile