1

(2 replies, posted in General)

Vladimir,
Thank you for the code example.
When I was looking through your code I got an idea so I checked my code and found out that I was really close.
It turned out that I was declaring the variable iDays twice.  So I was resetting the variable to 0 when it should have left it at iDays = 15.
Once I got rid of the second declaration my code now works OK.
.
Thanks
Frank

2

(2 replies, posted in General)

Hi,
I have a Nag screen that I use to administer a 15 day FREE Trial period.  If the date is within the 15 day period then the user can go ahead and continue the trial.
.
If the trial period reaches 0 then this code kicks in:
   if iDays = 0 then
    begin
      showMessage('----- Trial Period Has Ended -----') ;
      frmNagScreen.SetFocus
    end else
      frmNagScreen.close ;

.
This works fine.
However I noticed today that if the user doesn't come back to the program for a few days the iDays will go to -1 or -2 ....
Since IDays is NOT 0, then it lets the user continue to use the program.
.
I need to check for 0 and/or -1 at the same time.
Using my code above I can check for 0 or -1 separately, but not both at the same time.  I'm guessing I could maybe do it with an OR function but I haven't been able to make it work.
.
UPDATE: I just tried if iDays <= 0 then... and it worked because right now idays is 0.  So I guess I'll wait till tomorrow to see if it works for idays = -1, unless you have any suggestions?
SORRY: It looks like <= is not working after all.  So I'm back to my original problem.
.
As always your help will be appreciated.
Thanks
Frank

3

(15 replies, posted in General)

Derek,
I got it thanks.
Frank

4

(15 replies, posted in General)

Derek,
I've been looking over your example program and I don't see it doing anything?
I must not be understanding something??
Can you please explain how it works?
.
Thanks
Frank

5

(15 replies, posted in General)

Sparrow,
I agree completely with your explanation.  Last night, after I posted my question, I was thinking that I should just leave it to the user to decide whether they want full screen or not.  I know personally that sometimes I'm OK with a screen size as it is and sometimes I like full screen.  Youtube is an example.  Sometimes I just watch a clip in the smaller screen and sometimes I want to see more detail, so I make it full screen.
.
I believe I've been trying to make the program perfect when there's a point where it's fine as it is. 
.
Almost all of the basic functionality in my program is working fine now, thanks to the help you folks have provided me.
As I'm going through my final testing and clean up, I sometimes see something that I think could be changed to make it better.  However I now realize that some of my 'fixes' just might not be worth the effort.
.
Destiny, thanks for your suggestion, I'll check it out.
.
Thanks for your help
Frank

6

(15 replies, posted in General)

Destiny,
Trying to Maximize the form as you suggested is what I originally tried, and it didn't work out for me.
I may have other problems, please read on.
.
Derek, Sparrow,
I've been trying all kinds of things and I'm not getting the combination of settings that seem to work the way I would like.
.
I'd like to back up and ask a couple of basic questions:
First - Some time ago I asked about how to size my program to different size screens.  The forum was kind enough to give me suggestions as you always do.  And I know I learn things, but maybe not all I need to learn sad
I have some code in my main form ONSHOW . Here's a partial example of what I have:
if screen.width = 1920 then
   begin
     vscale := 170;
     //showmessage('w=1920, first check') ;
   end

.
for vi := 0 to Screen.FormCount - 1 do
  Screen.Forms[vi].ScaleBy(vscale,screen.pixelsperinch);

.
I test for a number of screen sizes and it works OK on the 2 different size laptops I have. (this was before I got into the Maximize issue)
I have no idea what it would look like on a desktop or a larger monitor?
.
And I have no idea as to what size of computer screen my user will have?
So my question is how do you folks size your applications to fit various size computer screens?
And also, eventually what do you do with the Maximize issue?
.
To me, it looks like this is quite important and I'm wondering what the different types of solutions are?
.
.
Thanks for the help all of you have given me over the last couple of years.  I'm now able to do quite a few general, simpler things by myself because of your help. But when I get into some of the things that I do, it quickly reminds me of how much I don't know.
.
Frank

7

(15 replies, posted in General)

Derek,
I had tried earlier to put the code you suggested in my frmMainMenu SHOW event
// Maximize the form
  frmMainMenu.WindowState := wsMaximized;

.
And it does work and it does Maximize the screen, however it does not go to the top of the screen.  There's about 1/4" of the screen behind my MainMenu screen.
And if I double-click on the double box icon it does make the screen smaller.
Then if I double-click on the single box it does Maximize the form and this time it does fill my screen.
Strange ??
I tried to get an image of what I'm describing but I was not successful.
.
I do use some scaling in the code for this form to get it to fit on my screen.  So I turned this off and it does the same thing.
.
I'll keep working on it.
Thanks
Frank

8

(15 replies, posted in General)

Hi everyone,
What I would like to do is to have ALL of my forms open MAXIMIZED.  I'm thinking that if this were to happen then my program would fit on whatever screen size the user has.  When I use the Maximize button on any of my forms it does exactly that.  However I think it would be nice if this were to happen automatically.  If my logic is flawed please let me know.
.
Here's what I have tried.
On the SHOW event of my Main form I put this code:
procedure frmMainMenu_Button1_OnClick (Sender: TObject; var Cancel: boolean);
begin
   frmMainMenu.WindowState := wsMaximized;
end;

This only works partially.
.
Next I created a button on my Main form:
procedure frmMainMenu_Button1_OnClick (Sender: TObject; var Cancel: boolean);
begin
   frmMainMenu.WindowState := wsMaximized;
end;

This works better and does seem to affect the other forms.  However I'd like to do this without the user having to click on a separate button if possible.
.
Your thoughts will be appreciated.
Thanks
Frank

9

(2 replies, posted in General)

Hi folks,
If I put a record in a table can I make it permanent and prevent the user from deleting it?
.
I have a Supplier table where the user can add and remove suppliers as needed.  But I would like to have one record with the name Unknown so it's always there.
.
It would also be nice when adding a new Equipment record that the Supplier Name shows Unknown shows up automatically, then the user can click on the combo box and choose a different supplier from the supplier table if they want.
.
There will be times where the user will not have a Supplier Name.
However if they leave the field BLANK, then I'm having trouble later on in reports.
-------------------------------------------------
UPDATE:
Here's what I did:
I created a SUPPLIER record with the name = - Unknown -
So when the combo box is sorted this entry comes up at the top of the list.
Then I found DefaultIndex = 0, so I changed it to DefaultIndex = 1
Now when I'm creating a new Equipment record the combo box for SUPPLIER defaults to - Unknown -
This means no more blank combo box fields.  And I can now use this record in reports.
.
So it seems like this technique solves my empty field problem.
However, my first question still remains.  How do I protect this record and not let the user delete it from the SUPPLIER table?
.
Thanks
Frank

10

(14 replies, posted in General)

Derek,
That's a great tip - thanks.
.
What I've been doing is putting things of value (or interest) in a Word Document for reference.
It's easy to search so that's a plus. In the 2+ years I've been using MVD, my Word Doc is now up to 41 pages.
Some stuff I've never used but others are very valuable.  It lets me find stuff that I've learned long ago so I don't have to rely on my aging memory. PS - don't get old LOL
.
But keeping things at the bottom of my script file, especially current items I'm working on could be real handy & save me a number of steps and time.
.
Thanks
Frank

11

(14 replies, posted in General)

Sparrow,
I believe I told you that my code was pretty messy.  It got so bad that I had to go back to an older backup to get the basic program working again.  That got rid of a number of the trial & error stuff that I had been putting into the code.
.
Bottom line is that, right now, most things are working as I would like.  Unfortunately I had the bad habit of making some change that doesn't work and not removing that change before I go on to try some other magic solution. 
.
Now the date functions and formatting have straightened out so they look OK.
The bad thing is that I'm not sure what I took out that was screwing things up. I must have had some changes that were messing with dates??
The good thing is that I'm back on track to completing the program so I'm not going to spend a bunch of time trying to figure out what I did wrong. 
.
One of the neat things I learned from you is the comment code /* some code */ inside a SQL statement.  It lets me experiment without just erasing stuff.
.
Thanks for being patient and helping me out.
.
Frank

12

(14 replies, posted in General)

Sparrow,
Your fix works great. The date format is now correct.
However now the tableGrid is showing ALL of the Service records.  It doesn't seem to be recognizing the MAX function.
.
When I run your sample program, the date comes out in the m/d/Y format.  I wonder why it comes out different in mine?
.
Thanks

13

(14 replies, posted in General)

Sparrow,
Many thanks for your help with this.
.
I've been using tablegrid 4 from your example program and so far it's been working OK.
I do have one issue though.  The MAX(SvcDate) if coming out in the format of
2022-08-12 00:00:00.000. Right now this is the only thing that is preventing me from having this SVC tableGrid working the way I'd like.
.
Most of the other dates in my program are in the format mm/dd/yyyy
I've been trying to modify the select statement below and everything I try seems to break it.
I'm sure most of my problem is that I'm a complete novice in SQL.
Here's the code I'm trying to use and it's OK except for the Date format.
(SELECT MAX(SvcDate)                 
FROM tbl_service
where tbl_Service.id_tbl_Equip = tbl_Equip.id)

.
One thing you mention is SELECT DISTINCT.
I don't know what that means and is it something I should be using?
.
You also mentioned about providing help for me over time. You are correct.
When I started in MVD over 2 yrs ago, I was a complete novice.  Since then, yourself, Derek and others have been guiding and teaching me.  Thanks to your help I'm now able to do quite a few things on my own = PROGRESS.
.
I think I'm close to finished and then I see something I would like.  Much of it is straightforward to me now.  But when I get stuck you folks have always come to my rescue.  And I try to learn from all the work that you do.
I really really appreciate it.
.
I know I should include my code so you folks can see what I've got and I'll go ahead and do it.  However, I want to clean it up first because it's really messy.  I've been adding and experimenting for so long now that there's a lot of stuff that needs to be taken out of my Script file. During my journey I've run into some instances where I had some basic design flaws.  So I've had to make some necessary changes, and of course that breaks everything it touches. So it takes me quite a bit of time to get back on track.
.
If I had to pay you folks for all you've done for me, you'd be rich and I'd be broke.  Not that I could afford it LOL.
.
Thanks again for all of your help.
Frank
.
Thanks again

14

(14 replies, posted in General)

Derek, Sparrow,
Thanks for giving me some things to try.
.
I've been trying to work your suggestions into my program and I haven't had any luck. Trying to fold Derek's changes into my code has been a real challenge. I'm sure part of it is because my table structures are different (and probably messy).  My program has grown so much that when I start trying to make significant changes I wind up breaking something,  Then I have to go to my backup copy & try again.
.
Derek - The tableGrid2 is the result I'm looking for.
However I'm afraid your solution is above my skills level.
One thing I don't understand is what this does & how it works? {services.cfmostrecent} = "*"
I know it's the calculated field but I've never seen the braces and the * used like this.
.
Maybe you could explain it for me? 
.
Sorry to be such a pain
Thanks
Frank

15

(14 replies, posted in General)

Hi Everyone,

I have a tableGrid that has a bunch of service records for different pieces of equipment.
I would like for the tableGrid to show only the records with the latest Service date.
.
Equip                Service Date
    Alternator                8/1/2020
    Alternator                8/15/2020
    Alternator                8/20/2020
    Engine                    7/1/2021
    Engine                    7/15/2021 

.
So for the Alternator I would like to see only the 8/20/2020 record.
And the same for each piece of equipment.
.
I'm thinking I might be able to put a select statement in the filter section of the tableGrid but I don't know how I might format the statement...if it's possible or adviseable.
.
Thanks
Frank

16

(8 replies, posted in General)

Sparrow,
I've been going over your example program (svc.zip) and it looks really good.
I've been wanting to save the results of a calculation into a field before and your solution shows me how to do it.
I believe using this approach will simplify things for me considerably.
.
While trying to implement it into my program I'm realizing I believe I have some design flaws in my program.
So it's going to take some work to make the necessary changes.
.
*** When I first posted this Reply I referred to add2 as a function or procedure.  Sorry I didn't realize that add2 is the name of the form.  I had a senior moment.
.
I will let you know if I have any problems.
(I have a tendency to get myself out into the weeds from time to time so I'm sure I'll be back)
.
Thanks so much for another valuable lesson.
Frank

17

(8 replies, posted in General)

Sparrow,
Do you know how I can save the results of OPTION 2 into a Text field.  I need that result to calculate when the next Service Due Date is? 
.
The calculation works but I only seem to be able to save the result in a calculated field.  I'm thinking if I had the result in a Text field then I could use it going forward.
.
Maybe this is not the best solution?
.
Thanks
Frank

18

(8 replies, posted in General)

Sparrow, k245
Thank you for the suggestions.  You've given me some things to think about.
.
I like Sparrows idea of storing the NEXT SVC DATE in a field instead of using a Calculated field.  Calculated fields are nice but there seems to be some restrictions when I want to use the info in that field to do something because it's not really saved data.
.
I'll have to change some stuff to see if I can make it work but it could be worth it.  I'll let you know how it goes.
.
Thanks
Frank

19

(8 replies, posted in General)

Hi All,
I'm trying to SORT a tblGrid using a Calculated Field.  But it's not working.  Here's what I have:
.
OPTION 1
calcNextSvcDate =
strftime('%m/%d/%Y',date(julianday((select max(SvcDate) from tbl_Service   
where tbl_Service.id_tbl_Equip = tbl_Equip.id)) + (select SvcInterval
from tbl_Svc_Interval where tbl_Equip.id_tbl_Svc_Interval = tbl_Svc_Interval.id)))

.
OPTION 2
calcYMDnextSvcDate =
strftime('%Y/%m/%d',date(julianday((select max(SvcDate) from tbl_Service
where tbl_Service.id_tbl_Equip = tbl_Equip.id)) + (select SvcInterval
from tbl_Svc_Interval where tbl_Equip.id_tbl_Svc_Interval = tbl_Svc_Interval.id))) 

.
When I use calcNextSvcDate the tblGrid does not sort by this column.
When I use calcYMDnextSvcDate it is working OK.
.
So that's good news for the SORTING issue.  However my problem is that the dates in the cells for option 2 are showing as Y m d and since I'm in the US, I would like it to show m d Y
.
First, is there any way to format the data in the cells in OPTION 2 ?
Second, is maybe my approach to the SORTING issue maybe not the correct way to do it ?
.
Thanks
Frank

20

(3 replies, posted in General)

Derek,

It turns out that my weird fix didn't work after all.  When I put in more test data the dates were coming out wrong.
.
So I went back into my Report(SQL) and used the Order By with my Calculated Field and I changed the date to Year,Month,Day - strftime('%Y/%m/%d',date(julianday(.... and it's now sorting my report correctly by the Calculated Date.
.
Thanks for the suggestions
Frank

21

(3 replies, posted in General)

Derek,

Thanks for the suggestions.
I thought I had tried both #1 & #2 however they didn't work.
.
Then after I saw your suggestions I went back & tried #1 again.
This time I added a field called NextSvcDate to my table.
.
Then I added ORDER BY NextSvcDate to my Report SQL statement and it works.
.
NextSvcDate is the Name of my Calculated field.
.
Nothing gets saved in this field in my table however which seems strange to me, but the Calculation does happen & shows up on my form.
So I'm guessing that the Report(SQL) picks up the calculated result.
.
This probably sounds confusing to you and it sure is to me.  But I get the results I was looking for so I'm not going to mess with it.  I feel like the blind squirrel who just found an acorn LOL.
.
Thanks for your help as always
Frank

22

(3 replies, posted in General)

Hi Everyone,
.
Can you save the results of a calculated field into a text field in a table?
.
I'm trying to save this result in a table field so I can use that saved result in a Report(SQL)  ORDER BY to sort my report.
.
I'm not at all sure if this the way to do it??
.
Any suggestions on how to sort a Report(SQL) will be appreciated.
.
Thanks
Frank

23

(3 replies, posted in General)

Hi All,

When doing some final testing of my program I've run into something strange.
-
I'm testing my program on 2 different PC's.  #1 - 1920 pixels wide and #2 - 1366 pixels wide.
-
My program was written and seems to work fine at 1920 pixels.
However when I test on a 1366 pixel PC the TableGrids do not adjust to the screen width.  They become quite wide.  The horizontal scroll bar does appear and I can see everything when I scroll left and right, but I don't understand why the TableGrids don't seem to change with my screen size?
-
I check for the screen size with this code:
...else if screen.Width = 1366 then
    begin
      vscale := 120;
    end

.
All of my forms on the 1366 PC fit OK on the screen.  It's just the TableGrids that don't seem to change with the forms.
.
UPDATE: I just noticed that the TableGrid box does change in size according to the size of the PC.  It seems that the individual cells in the TableGrid do not change according to the screen size.  I do see that if I use the vertical bars in between the cells to change the width of each cell, then I can make it all fit in the TableGrid box.  And everything seems to look OK.
-
So I'm thinking that I might just have to tell my users to use the vertical bars to adjust the cells to fit their screen??
-
Your comments will be appreciated as always.
-
Thanks
Frank

24

(8 replies, posted in General)

Hi Derek,
I see what you're doing and it does work.....but there's always a but smile
.
What I think would be nice is when the new date field is visible it would show __/__/____
And then I would be able to put the mm/dd/yyyy in each part of the date field, without having to use the calendar and go through a lot of steps.
.
However it looks to me like the Datepicker field just doesn't work that way.
.
However thanks to your example code I found a solution that I believe is the closest to what I was looking for.
For a New Record
- I use your panel over the DATE portion of the field and I leave the check box visible
- So when you open the form the date field appears empty
- Then when I click the date field check box I make the panel go away, thus exposing the rest of the date field
- It does show today's date but at least the user is focused on the date field and should be more inclined to put in the date they want
- I can then change the date by either clicking on the individual elements or use the calendar drop down function.
.
Then if I'm editing a record that already has a date in the Date field, I check to see if the box has been checked and if yes, then I remove the cover up panel.
.
It's a pretty neat solution
Thanks
Frank

25

(8 replies, posted in General)

Sparrow,

I don't really need a calendar. The Date field is nice and has a lot of bells and whistles, but I find when I'm  in a date field it seems to be easiest to just type in the date - like 06/22/2001.  If the default date could be set to __/__/____ then I think it would be nice. And simple.  But I couldn't find any way to set it like this?
.
I'll play around some more with my Date Text box & see how it goes.
.
Thanks
Frank