Hi,
Not quite sure what your issue is with displaying 'days left' in a tablegrid; there are a number of ways to do this.
Have a look at the attachment as one option and get back if anything is unclear.
The 'days left' and 'duration days' are actually displayed in the caption of Form2 instead of in text fields (simply because it's something that the user does not have direct input to) but the text fields are just hidden so if you prefer to display it that way, just make them visible again.
NB: the actual calculation of 'days left' and 'duration' varies depending on whether your date range is 'inclusive' or 'exclusive' but this is just your own preference - the principle remains the same.
Regards,
Derek.
1 Yesterday 18:14:20
Re: textBox date time format (12 replies, posted in Script)
2 2024-04-19 11:54:52
Re: Скопировать значение из Footer таблицы (4 replies, posted in Russian)
Привет,
Попробуйте вот так.
Derek.
3 2024-04-18 10:19:18
Re: incompatible Value (5 replies, posted in Script)
Hi,
It's a lot easier if you attach your project - then it's possible to be totally sure what your problem could be.
However, in the case of this error message, it almost certainly refers to the fact that you are referencing a column in a tablegrid that doesn't exist (remember that column and row counts start from 0 and not 1).
Some general points to also consider.
1. every cell in a tablegrid is handled as 'text' (or 'string'). So if you want to display the contents of individual cells in a message box, you can do this directly without needing to use a variable or worry about converting to a specified field type (see line 9 in the script).
2. the contents of any cell can be copied and displayed in an 'edit field' because no conversion is needed (because all cells in a tablegrid are held as text, as explained above); see line 7 in the script and try changing the column no' to something else and you can see that it still works.
3. if you need to copy and display, for example, a date/time value from a tablegrid (text) in a 'datetimepicker field', you need to explicitly convert it (see line 8 in the script). This is also true for other field types.
Hopefully that makes things a bit clearer.
Regards,
Derek.
4 2024-04-17 00:11:27
Re: Combo to memo and RTF insert (4 replies, posted in General)
Hi Adam, Hi Konstantin,
Is this the sort of thing you are trying to do? (see attached).
Looking at your project, I couldn't see why you can't just use one table ('phrases') rather than two discrete tables ('phraseplain' and 'phrasertf'); in your example, phrases in both tables are held as plain text and it's only when you copy something into 'frmitems.rtf1' that you can add 'rtf' formatting etc so it just seemed easier to simplify things with one 'phrases' table.
Also, I wasn't sure why you needed to have relationships between the 'items' and the 'phraseplain' and 'phrasertf' tables when they work more as 'standalone lookups'
Or am I missing something in the greater scheme of things! Probably!
One issue I can't seem to find a way around is that if you amend the 'rtfnote' field on an existing record by copying in more phrases, it loses any previous formatting that you had - but I seem to remember something like that happening before with one of your projects from a couple of years back.
Regards,
Derek.
5 2024-04-16 14:53:59
Re: Looping through tablegrid using inputquery (4 replies, posted in General)
Hi Sparrow, Konstantin,
Excellent - both solutions do exactly what I need. Specifically:
1. I hadn't really appreciated how using
'while vi <= form1.tablegrid1.rowcount -1'
behaves differently from
'for vi := 0 to form1.tablegrid1.rowcount -1'
2. I also wouldn't have thought to use 'break' to interrupt the 'for vi: = 0 to form1.tablegrid1.rowcount -1' loop.
As always, everything becomes so clear and obvious once someone shows you how!
Thanks to both of you for your help.
Regards,
Derek.
6 2024-04-16 11:03:09
Topic: Looping through tablegrid using inputquery (4 replies, posted in General)
Hi All,
Some help please if anyone has any suggestions.
I have a tablegrid that I am looping through and using 'inputquery' to update each row.
In the attached example, click on 'Update Status' to start processing through the table. Valid inputs are 'A' (Approved') and 'D' (Denied). This works fine.
The problem is when something other than 'A' or 'D' is input. I trap the error using 'messagebox' and when the User selects 'Retry', I need to remain on the row in the tablegrid where the error occurred.
Everything I have tried so far detects the error but advances to the next row in the tablegrid by which stage it's too late.
Using MVD 6.1 and Windows 10.
Any ideas would be most welcome.
Derek.
7 2024-04-13 18:06:48
Re: loop in Table (8 replies, posted in General)
Hi,
The conventional way is to load all the data into a tablegrid and then loop through each row and perform whatever calculations / checks you need.
Have a look at the attachment which gets a 'discount rate' from a look-up table and calculates a 'sale price' for each item in the 'items' table.
You can then either 'clear' the 'sale price' or change the 'discount rates' and then recalculate the 'sale prices' etc etc.
Obviously there are other checks and controls you would want to put in place but this is just to show you the basics.
Derek.
8 2024-04-12 00:19:55
Re: loop in Table (8 replies, posted in General)
Hi Lara, Konstantin,
If I understand the question correctly (an identical calculation for all rows in a table with the result added to a "result" column), perhaps this will do what you want (attached is a simple example).
Derek.
9 2024-04-10 19:54:36
Re: ДАТА и ВРЕМЯ... (35 replies, posted in Russian)
Привет,
Сделать это можно двумя способами (см. строки 7-8 скрипта в прилагаемом примере).
Второй способ (строка 8), вероятно, немного более эффективен, поскольку позволяет избежать дополнительных обращений к базе данных.
С уважением
Derek.
10 2024-04-10 13:29:34
Re: Помощь 4 в проекте для Новичка (8 replies, posted in Russian)
Рад, что это помогло.
Я также еще раз рассмотрел вашу предыдущую проблему (окрашивание строк в сетке таблицы в зависимости от того, сколько им лет) и добавил фильтры по их категориям — щелкните сводку категорий внизу «Формы 1», чтобы отфильтровать их по соответствующей категории.
Возможно, это тоже помогает.
С уважением,
Derek.
11 2024-04-09 17:04:47
Re: What is the simplest way to copy a record in a table without coding (5 replies, posted in General)
Hi,
Yes, it is possible (sort of!) without any code.
Have a look at the attachment.
TO CREATE a record
1. click on the 'create' button
2. enter your details
3. click 'copy/save' to save your new record
4. close the form.
To EDIT a record
1. double-click on the row in the tablegrid you want to edit
2. make any changes and click 'copysave' to save your changes
3. close the form
To COPY a record
1. double-click on the row in the tablegrid you want to edit
2. click 'copy/save' first (this prevents the selected row from being overwritten
3. make any changes (if creating a copy BASED on the selected row) and / or just click 'copy/save' to create your new record.
It sounds a bit complicated but just try it out in the attachment and it should be straightforward.
Just be careful when doing this as it is very easy to create duplicate records unintentionally.
Regards,
Derek.
12 2024-04-08 10:22:23
Re: Reminder alerts (9 replies, posted in General)
Hi Adam,
I use a much simpler version of what you have built but instead of using a toggle to 'stay on top', mine always 'stays on top' but I then hide it off to the side of the screen when it's not in use.
In the attached example, click on the date to hide Form1 and to bring it back, move the mouse to the left of the screen to where it's been docked.
Maybe it's something you might find useful.
Regards,
Derek.
13 2024-04-06 12:55:55
Re: Помощь 4 в проекте для Новичка (8 replies, posted in Russian)
Извините, мне кажется, я неправильно понял ваш вопрос.
Мое понимание сейчас
1. Вы хотите сохранить идентификатор последней сохраненной записи (которая не обязательно является последней созданной записью).
2. При создании нового набора данных вы хотите загрузить соответствующие данные из последнего сохраненного набора данных, и это может быть либо
2a — последний набор данных, сохраненный в этом сеансе.
2b — это последняя сохраненная запись предыдущего сеанса (т.е. программа была закрыта, а затем перезапущена).
Если эти предположения верны, посмотрите приложение.
Derek.
14 2024-04-06 12:01:05
Re: Помощь 4 в проекте для Новичка (8 replies, posted in Russian)
Привет,
Если я правильно понимаю вопрос, возможно, более простой способ — просто скопировать последние значения из Form2, а затем перезагрузить их при создании новой записи.
Derek.
15 2024-04-05 17:19:40
Re: Some question's (9 replies, posted in General)
Hi,
Have a look at the attached. Hopefully it is closer to what you have described.
1. Above the tablegrid is where you specify the range of dates that you want to generate.
2. Below the tablegrid is where you specify 1) the range of dates you want to delete and / or 2) the 'day number' of the week that you want to delete (for example, to remove all dates that fall on a Sunday, enter 1 then click delete etc etc.
Hope this helps,
Derek.
16 2024-04-04 23:53:57
Re: Some question's (9 replies, posted in General)
Try it something like this (see attached).
Obviously you'd need to add some sort of error checking to prevent duplicating date ranges.
I'm not sure what the point of having the 'day number' displayed is when you could just show the actual 'day of the week' as part of the date (ie Fri, 05/04/2024) but maybe you need the actual 'day number' for some reason.
I have no idea what causes the problem you mention when working on a form; as far as I know, no one has ever had any issues like that. One possible thing might be that you are not pressing 'enter' once you have made a change to an object (for example, if you change it's name) but I doubt it's that.
Derek.
17 2024-04-04 15:47:33
Re: Some question's (9 replies, posted in General)
1. See attached.
2. form1.menu := nil is one way to prevent the standard windows menu from appearing on the start form.
Derek.
18 2024-04-04 12:32:19
Re: onTop (3 replies, posted in General)
Hi Adam,
Perhaps try something like this (see attached).
Derek.
19 2024-04-03 19:32:06
Re: Report items change (9 replies, posted in General)
To add the 'day of the week' as text in FastReport directly, you could
1. add a memo field and place it on the report layout (see the screenshot in the attachment).
2. create a 'before print' event for the Master Data band (see the screenshot in the attachment)
3. insert the code that Sparrow gave you in a previous post or use the code already there (see attachment).
There may be other (better) ways to do this - I don't use FastReport very much so I'm probably not the best person to ask.
Derek.
20 2024-04-03 10:43:04
Re: Report items change (9 replies, posted in General)
To use a calculated field:
1 create a new field in your table with a field type of 'calculated field'
2. add the code (exactly as already detailed by Sparrow)
3. display the calculated field in the tablegrid (optional)
4. add the calculated field to the field selections in the 'report' action.
5. the calculated field can be referenced in 'FastReport' like any other field type.
Have a look at the attachment and the included screen shot.
Derek.
21 2024-04-02 10:13:23
Re: Report items change (9 replies, posted in General)
Hi Samtom, Hi Sparrow,
Personally, I would probably use a calculated field as suggested by Sparrow.
However, if you are not yet familiar with how to create a calculated field, another option is to hold the days of the week in a look-up table (see attached).
You also need to be careful viewing and creating records on the same form (Form1); it is very easy to inadvertently create duplicate records if you have not added a bit of 'script' to prevent this.
Derek.
22 2024-04-01 12:50:35
Re: help me please (1 replies, posted in General)
Hi,
Sorting in the tablegrid is disabled on a column by column basis
procedure Form1_TableGrid1_OnChange (Sender: string);
begin
Form1.TableGrid1.Columns[0].Options := Form1.TableGrid1.Columns[0].Options - coCanSort;
end;
Then repeat this code for all the columns that you want to disable sorting on.
Derek.
23 2024-04-01 10:20:30
Re: Скопировать значение из Footer таблицы (4 replies, posted in Russian)
Привет,
Попробуйте вот так
form1.edprice.Text := form1.GridPartsUse.columns[3].footer.caption;
Derek.
24 2024-03-31 22:55:26
Re: Search multiple fields using one Input (1 replies, posted in Script)
Hi Sonixax,
Try using a calculated field that concatenates all the individual fields that you wish to search on.
Please be aware that you need to use 'ifnull' in the syntax of your calculated field, otherwise a row that contains an empty field (ie first name is blank or middle name is blank or last name is blank) will not show in the search results.
Alternatively, if the fields you use in your concatenation are all mandatory, then this is not an issue and the syntax of the calculated field is simpler.
Have a look at the attachment as an example,
Regards,
Derek.
25 2024-03-30 21:23:01
Re: Помощь 3 в проекте для Новичка (7 replies, posted in Russian)
привет,
попробуй вот так.
Derek.