1

(3 replies, posted in General)

Salut Destiny,
Is this the sort of thing you want (see attached)?
In the example, you 'mouse down' on the label at the top of the form (but you could attach the code to any object you choose).
Regards,
Derek.

2

(2 replies, posted in Russian)

Здравствуйте Vickus,
Возможно, проблема в том, как вы определили поля в схеме вашей базы данных.
Вы определили поле «Паспорт» как «текст» или «целое число» (даже если поле может содержать только числа, если вам не нужно выполнять никаких вычислений, его все равно следует определить как текст)?
Попробуйте определить поля как текст, и все, что начинается с «0», должно отображаться правильно.
Derek.

3

(10 replies, posted in General)

Hi,
Here's a working example - if you copy the code, it should be okay (or if not, attach your project to see what the problem might be).
Thanks to Sparrow for the solution.
Derek.

4

(10 replies, posted in General)

Hi Sparrow,
I did wonder about calling a bespoke procedure from the 'form1.onclose' event but I'd always thought that the 'form1.onclose' event would always run first before any other called procedure - but it seems that it's the opposite way round.
Knowing this now, I can see it being useful in quite a few scenarios.
So much still to learn sad
Thanks,
Derek.

5

(10 replies, posted in General)

Hello All,
I don't think this can be done when clicking on the 'x' icon (top right of form) to close the form.  When this is clicked, the 'formclose' instruction has already been actioned and any message that you display (whether using 'messagebox' or 'messagedlg') is really just for information - it's already too late to cancel.
The only way would be to create your own 'formclose' button and then attach code to this (but then do you leave the 'x' icon in place and visible (rather confusing) or do you set the form 'border style' to 'bsnone' (which means you loose the ability to drag the form)?
All of the possible solutions are, unfortunately, a bit of a compromise to what V_Pozidis really wants.
Derek.

6

(9 replies, posted in General)

Hi,
So you want to be able to search (for example) by name across all the tables ('administration, 'amis', 'sante', 'famille' etc).
It could be done but I think I would use a different approach entirely.
My advice would be to initially look at your data schema -  your tables all have the same structure and differ only by the type of contact.  Your whole project would be a lot more straightforward if you used just one table ('contacts') and a related table ('contact types') - see the screenshot attached.
This would resolve a lot of your issues (including the question of searching for something across multiple tables) and possibly solve issues that you haven't yet come across. 
It would also make your project easier to maintain as you could easily combine your forms for 'Famille', 'Sante', 'Entreprise' etc etc into a singe form ('contacts') where you could use a combobox to choose the 'contact type'.
One final point - be careful using the same form for viewing, inserting and editing your data as it can cause quite a few problems that you simply don't need to worry about if you use discrete forms.
Derek.

7

(9 replies, posted in General)

Salut Destiny,
Have you got an example project you can upload to show exactly what you're trying to do - I'm not quite sure what you need.
Merci,
Derek.

8

(17 replies, posted in General)

Hi,
Please see the attachment.
1. The date is now entered as part of the 'save' button on 'frmapografi'.
2. On 'frmpin', filter rows by selecting a date and clicking button 'filter records for the selected date'
3.  On 'frmpin, you can now delete records by the selected date by clicking button 'delete records for the selected date' (this may be useful if you insert records accidently into 'pin' or create duplicates).
4.  frmpin.tablegrid1 is now an editable grid ('change only)' in case you need to make small adjustments (for whatever reason).
Regards,
Derek.

9

(17 replies, posted in General)

Hi,
Try it something like this (see attached).
I've added a 'date' column to table PIN - I'm not sure how you plan to use table PIN but I'm guessing you will be doing multiple 'saves' so you'd need some way of filtering the saved data.
I've also added a button (frmpin)so you can view exactly what has been saved to table 'PIN' ;  on 'frmpin'),just select a date to see the relevant extract.
Regards,
Derek.

Hello All,
Yet another variation on the same theme is to use the tablegrid's in-built footer function and then hide the footer.
The footer values (count, sum, minimum, maximum, average, distinct) can then simply be copied into edit fields.
Derek.

11

(17 replies, posted in General)

Hi,
When you use 'group by', it also does a 'sort by' at the same time.  So if you group by EAN, then that is the sort sequence in which it appears.
A possible solution would therefore be to sort ALL of the tablegrids by EAN to force them to be in the same sort squence.
Derek.

12

(17 replies, posted in General)

I don't quite understand what you are trying to do.
Can you take a screen-shot (perhaps use Excel) to show exactly what columns and rows in the tablegrid you want to display.
Derek.

Привет,
Попробуйте что-нибудь подобное.
Это не совсем то, что мне нужно, но размер файла (в базе данных) отображается автоматически (для уже сохраненных изображений) и отображается после того, как курсор мыши убирается с изображения (для новых изображений, которые еще не сохранены).
С уважением,
Derek.

Привет,
Думаю, это возможно, но отображать размер файла не так-то просто: сначала его добавляют в форму, а потом, ДО сохранения в базу данных, — не совсем удобно.
Разве недостаточно видеть размер файла при его выборе (см. вложение)?
Derek.

I think it can be done but it is not quite so easy to show the file size when it has been added to the form but BEFORE it has actually been saved to the database.
Is it not enough that you can see the file size when you are choosing it (see attachment)?

Привет.
Вы можете рассчитать размер существующих изображений следующим образом (размер указан в байтах (для тестирования), поэтому просто разделите на соответствующий коэффициент, чтобы получить результат в килобайтах или мегабайтах).
Derek.

16

(2 replies, posted in General)

Salut,
Try adding this line to your code

procedure Accueil_Image3_OnClick (Sender: TObject);
begin
  Famille.Show;
  Famille.TableGrid1.dbupdate;
end;

But be aware that when you try to do everything on just one form, it introduces a few extra problems (duplicate records, searching behaviour etc). 
Regards,
Derek.

17

(5 replies, posted in Database applications)

Salut Destiny, TCoton,
It is an unusual request - perhaps you could explain in more detail what you are trying to do.
When you hear about someone having two or more tables with identical structures, it is usually because they are trying to differentiate between something (for example, a table ('electricalproducts') for electrical products and a table ('mechanicalproducts') for mechanical products). 
It can be done but the usual approach with a relational database would be to have one table ('products') and then differentiate between the type of products by using a look-up table ('producttypes').
Having just one main table ('products') makes your processing much more straightforward and also future-proofs your application - if you need more product types (eg 'hydraulic'), it's simply a new row in the 'producttypes' table that the user can create) as opposed to creating a whole new table in your data schema and then having to redeploy your application.
Have a look at the attachment.
Derek.

Hey Adam,
Not sure if this (see attached) is getting closer to what you want.
Even if it's not quite behaving as you expect, I think it's a more straightforward way to go (ie using labels (which will also eliminate the flickering problem you had using images)).
Running out of time here so not checked (Caveat Emptor - LOL!!) and the code isn't commented (but it's reasonably self explanatory).
Derek.

Hi Adam, Sparrow,
Had a quick look at your project and, for the sake of keeping things as simple as possible, I'd be tempted to go with buttons instead of images.
Please see the attached which is just a suggestion but might give you some more options.
If you use 'styles' then
1.  buttons can be used as tabs - place them in a panel so that the bottom of the buttons get cut off so you then get a pretty close visual 'tab' effect (ie straight at the bottom and rounded corners at the top);  they can obviously be as wide or as narrow as you want (referring back to a previous issue you raised) and each one could differ in width if required..
2.  each 'tab' gets highlighted when 'moused over' as part of standard functionality.
3.  when you click a 'tab', the highlight remains and the selected color is displayed along with the relevant tabsheet.
4.  if you 'mouse over' any of the other 'tabs', they are then highlighted but the color of the previously selected 'tab' remains set (along with the relevant tabsheet) until a 'tab' is clicked at which point the previously selected 'tab' color is re-set and the newly selected 'tab' color is displayed etc etc.
That seems to give you the options you mentioned in your post and with very little code (always my goal big_smile).
Derek.

Hi Sparrow,
Good spot! 
Derek.

Hi Adam, Salut Jean,
Another way that would give you the most flexibility would be to make the tab widths variable so you can move them to whatever width you want.  Just drag each 'tab' to make it narrower or wider  (see attached).
Derek.

Hi Adam,
Short of creating your own page control from scratch (if even possible), I don't know of any way to reduce the width of the tab to less than the default minimum.
A possible option that keeps all of the usual page control functionality might be to simply hide the tabs and replace them with buttons (as per the attachment which can be sized to anything you want) or even images of different coloured tabs and that sort of thing if you wanted to get more creative.
Derek.

Olá Roberto,
Como vai você?
I vaguely remember having a similar problem a few years back but can't remember any details sad.
Maybe if you can attach your project, someone might be able to spot the reason (but you're right - normally it would remember column widths from the previous session).
Derek.

24

(17 replies, posted in General)

Hi,
You need to use a different procedure when you are using the 'enter' ('return') key as opposed to clicking on the 'save' button with the mouse.
The problem when you use 'editable tablegrids' is that if you use the 'enter' key, then it is difficult to check for any input error before the insert to the table has taken place.
I find that the easiest way to stop this is in your script by
1.  setting the 'save' button to not be the default (frmapografi.button1.default := false) to prevent the record being saved when clicking 'enter'.
2.  then test for the error.
3.  then depending on result of the test, switching back frmapografi.button1.default := true.
Have a look at the attachment.
n.b.:  the line of code (key := #0) is just to stop the annoying 'beep'!!
Derek.

25

(4 replies, posted in General)

It's a bit inconsistent depending on the component type.
For panels, there isn't really any visually noticeable difference between 'styles' off and styles 'on' (no slightly rounded corners etc) so i'd just use

tdbPanel(form2.components[vi]).styleelements := 0;

I imagine there will also be inconsistency with group boxes and page controls/tab sheets but I've never tried it (I tend to mainly use it for button captions and for text color inside edit fields).   At the end of the day, it's just a bit of trial and error!
Derek