76

(10 replies, posted in Script)

Hi dbk,
.
Yes, that's usually how I handle it.  Except I have been using

frmMain.PageControl1.TabIndex := 0;

I glanced over the help documents comparing the two, but I didn't quite understand the difference. hmm

Hi all,
.
I wasn't planning to check for duplicates on the groups, but I wanted to see how far I could go... not very far neutral
.
The other duplicate checking examples that I found were dealing with a single table.  And this takes it a bit further, or either I'm over-complicating it.
.
I started the code, but this may not be the ideal approach.
.
Thanks in advance for having a look.

78

(10 replies, posted in Script)

Hi derek,
.
Pardon me for overlooking that suggestion. I haven't really thought about using the database for persistent settings like that.  Very handy though!  I'll have to remember this for later on.
.
Many many thanks as always and for your examples too!

79

(10 replies, posted in Script)

Hi again,
.
So after further experimenting with derek's first option, I would like to clarify something, which is why I prefer the scripting method for this...
.
Changing the TabIndex property within the PageControl, is the same as selecting that tab in design mode.  Thus, the tab that was last selected becomes the tab that is first shown when the form loads.  So the TabIndex property in the PageControl is not fixed because it also changes to the tab that was selected prior to running the project.
.
To me, this is not really "setting a default".  Because while I'm designing a project, I don't always go back and select the tab that I wish to show when the form loads (mostly because I forget to do this).
.
It would be nice to have this option without scripting though...
.
Just my two cents wink

80

(10 replies, posted in Script)

Hi tjohnson0473 and derek,
.
A little late here, but great questions. I learned something, so I just wanted to comment.
.
I knew how to set the tabindex with scripts, but I wasn't aware that the PageControl had a property for doing this.  Or if I did, I had forgotten about it and had been doing it with scripts.
.
I have also noticed the behavior you described in your first question, but I've never been able to identify what was causing it.  I always tried to control it using the TabOrder properties, but this further explains the unsolved mystery for me.
.
Thank you, thank you big_smile

Thank you sparrow, that's precisely what I am after.  I'm glad this can be done. big_smile

Hi again,
Is there a way, by scripting, to invoke that MVD tool tip that shows for the not null fields?

This field is required. Please enter a value for the field.

I found threads describing how to translate the message and other alternatives for indicating required fields.  But I would like to keep it consistent with the other buttons that use the button Save action if possible.
.
Thanks!

Hi derek,
.
Just to recap on my latest post in here.  I'm not loosing my mind (yet).  I had this figured out already.  But now my users are asking for date and time ranges, so I had to revisit some past posts here too.  That's the reason for the seemingly revisit to this issue (again).
.
I experimented with your solution some, and it is possible to use a cfField to do what I needed (thanks to your example). However, one thing I noticed with my second requirement mentioned below; you cannot share form controls being used for the Date/Time field when the date and time are being used separately.
.
So I come to this conclusion (guideline):

  • When there will always be a date with an optional time, it can be done using a single date/time database field.

  • When both date and time are optional, this requires the date field and time field separately in the database.

  • There probably are some other cases to be included here too...

.
I wasn't aware of these, and it always bugs me when I open the database externally and see a perfectly good date/time combination using any of the three MVD fields: date/time, date, or time.  I'll just have to mentally ignore my OCD here. lol
.
Anyways, my apologies for stating the obvious to those more experienced.  And as always derek, I appreciate your examples and advice.

84

(8 replies, posted in General)

Heya papafrankc,
.
Try to prefix your code with:

frmEquip.cboInstalledSpare.Items.Clear;

85

(3 replies, posted in General)

Awesome Agilefalcon,
.
I didn't realize there were that many other options available.  But then again, I haven't really looked much further than MVD- once I found it wink
.
I briefly looked at the VisualNeo website, and if DMITRY decides to part ways with MVD then that will be my next option.
.
I don't consider myself a programmer, but I enjoy the challenges of learning how things work (and creating things from it).
.
Thanks again for taking time to comment cool

Okay- I may be back-stepping a little bit here...
.
So I'm wondering if it would be more simple, since I'm already using a DateTime field to represent both Date (and optional Time) together, using a single tableGrid column...  In a previous post, I was trying to separate these two.  And it is working perfectly, BTW.
.
The new column format is set to:

TNxdateColumn(frmEmp.TableGrid1.Columns[0]).FormatMask := 'mm/dd/yyyy HH:MM';

.
I don't care about seconds (which shows by default) so I would like to eliminate that part.  Is there a way to conditionally format this further to only include a range of times?  I'm only interested in showing the times within a window. Specifically between 06:00 and 18:00, otherwise I only wish to show the date (and exclude the time portion if possible) from the column.  Which in the case for this project, the time is set to 00:00 when it's not needed.
.
Example:
Date  /  Time   Column
11/02/2021
11/05/2021 06:12
11/10/2021 13:00
11/13/2021
11/16/2021 15:00
11/20/2021
.
Is there an easy way to achieve this, or should I just keep them separated?

87

(9 replies, posted in General)

Well, I'm reconsidering my suggestion for commenting now neutral
.
I've been enrolled in a few programming classes over the past year or so.  And I realize these are entry level courses, but they emphasize heavy commenting on our code.  We get penalized otherwise.
.
I guess there is a fine line here because Teco would fire me lol
.
I appreciate the feedback and also for the references.  And thanks to derek for being sypathetic on us wink

88

(3 replies, posted in General)

lol It's 99$... lol
.
Show me another product similar to MVD that even comes close to that price (even on Black Friday).
.
I second Agilefalcon's opinion:

MVD is, in my humble opinion, undervalued. It is very inexpensive, perhaps too inexpensive and when compared with popular other near no-code database applications is a fraction of their cost (Filemaker, Ninox, Airtable, Access - and some of these aren't anywhere close to "no-code").

.
I made a big mistake for purchasing a copy of Filemaker, and I even went against a good friend's advice doing it.  If only I had learned about MVD sooner. neutral

89

(9 replies, posted in General)

Hi papafrankc,
.
I wish I could offer you some useful help here.  But I run into this same thing all the time (it seems).  I'm always tempted to write sub-procedures for repeated code, but then I start redesigning my forms to help compensate instead.
.
I can't see your whole project, but for me I try to separate forms (which derek has suggested, in some of my cases) instead of trying to capture all kinds of variations.  Again, this may not apply for you though.
.
Commenting is your best friend, which you are doing, so I think you have the bases covered.  I start commenting almost every line when it starts getting too cluttered.  Because when I'm going back (months, or years) later it's easier for me to read my notes instead of converting what the code is doing in my head.  lol
.
I will be curious if others have better suggestions for you with this too.

Hi sparrow, derek
.
I appreciate both inputs!
.
derek:
Your answer is where I was headed in the earlier project when you suggested not using a separate form.  big_smile  I realize that you were not aware of where I was heading with the project at the time, but I'm appeased that you are now confirming my original direction for it.  And as always, for your example project.
.

If you want REALLY simple...

[edit]
I too am always seeking the simplest way.  The amount of scripting that it takes to hide and show form components during different stages is what prompted me to ask this question.  I start to loose focus on what is happening mad and get bogged down.
.
Thanks also to for stepping through your thought process for this method.
[/edit]

Okay, so moving forward.  I'm starting to build multiple save buttons depending on where the frmAtt (is called) originated from.  What's the best way to handle this scenario?
.
I found this post doing a similar thing with labels, but I'm stepping into unfamiliar territory here...
.
Depending on where the form is called, I want to hide certain controls because they're not applicable.  The project I've attached is a simple example using ShowMessages to demonstrate my idea.
.
Currently, I have two different places where the button is called, and I need to hide (or do something special) for each case.  The Apply To Group button is one instance. When the new record button is called from the frmEmp it needs to do something different.
.
To me, this seems like I may be over-complicating things, and I feel like there might be a better way to approach this.  Would someone offer extra advice here?  I would appreciate it.  Any thoughts or ideas?

Awesome.  I really appreciate that master derek!
.
Well I was experimenting with the tstrings.  I know it was an overkill, but it helped me demonstrate my example too.  Still learning the MVD ropes.  [edit]I forgot to mention that, your example showed me how to do it the right way. wink[/edit]
.
I found some examples using the sqltransaction commands, and they were updating 1000+ records at a time.  I don't foresee that many for this project, but thank you for mentioning it.
.
Another thing I notice in your example- you remove the public empID integer.  I tend to do this in most of my projects (I'm guessing it's unnecessary tho).  Whenever I go between forms, it is how I reference which parent ID was selected.  And sometimes I use the cfID=id method too.
.
Thank you again!

Sub-thread title: Add child records to parent records listed in the TableGrid


Hi folks,
.
Instead of creating another thread, I'm continuing this one since it uses the same project.
.
So, I'm progressing a little further with it, but I could use some more advice before I implement it into the working project...
.
The interface is working as desired:

  • Once a department group is selected, then the Apply to Group button allows for a mass update of attendance records for each one in that group.

  • The cyan textbox is showing the parent IDs to add new child records for.

  • I'm not sure if it's necessary to create a separate (identical) form for this case, but I did.

  • The MessageBoxes are temporarily shown, of course, as an example.

.
I don't recall anyone else on the forum doing or requesting this.  But as of right now, I'm thinking of using a script to loop a SQLExecute for each ID in the tableGrid to create the appropriate child records.
.
This is my idea for how to approach it, but I wanted to get some outside opinions first.  Is this a good way (notice any flaws?), or suggest a better (more simple) approach?
.
Thanks!

94

(9 replies, posted in Reports)

cfDerek,
.
Yeah- I didn't mean to imply that the calculated field was the only way.  But at this time, it has been the only suggestion that solves this sub-request.  It's not really an issue, maybe just a minor nuance.
.
I guess I was merely saying that I understand why you choose to stick with the cfFields (that work using MVD) rather than in FastReport.  Because they do EXACTLY what we intend for them to do, regardless of the behavior that the user's OS is defaulting to.  (which in most cases, they aren't even aware)
.
But again I would like to say that I can understand both sides here.
.
Thank you once again and many more. :salute:

95

(9 replies, posted in Reports)

Thanks again cfDerek cool
.
Up until a few minutes ago, I thought I solved it using sparrow's steps.  But it turns out that I was using a different PC, and evidently the date formatting on that PC uses a slash / as the date separator (so I thought it was fixed), and on this PC it's using the dash - instead.  However, this is a tedious detail that I wanted to point out.
.
So the cfField is the best way to fully control the formatting here.  It's kinda interesting that FastReports ignores the special formatting characters explicitly defined within one of its own field's property settings though.  But, I guess this falls into one of those controlling the interface arguments. roll
.
I'm starting to see now-  the reason for your new nickname. lol

96

(9 replies, posted in Reports)

This is the result from (the next step in) my project since I didn't post one for this question...  I went back and adapted the project for this post from another thread.
.
Everything is working perfectly, but I have another very minor question (mainly just out of curiosity).  I'm using mm/dd for the dateTime format in the report, but it's showing mm-dd instead.  My guess is that it's using the Regional format settings from the PC for this.  Is there a way to force a slash / instead of the dash - for this case?
.
[edit]always forgetting to attach the file tongue[/edit]

97

(9 replies, posted in Reports)

Hey sparrow and derek,
.
As always thank you for the suggestions!
.
derek is all about those calculated fields lol  I was experimenting with that approach as well, but I couldn't get it working.  Forgive me for not throwing together an example solution for the question.  And MANY thanks for providing us one here!
.
I was able to get both of your methods to work, but I had to do some minor adjustments with sparrow's code because it kept throwing an error about the report field not being a valid time.  I don't fully understand the syntax in FastReport with the brackets <> and [] and ().  Because of this, I get unexpected results usually.  Anyways- I managed to get it working.
.
I really appreciate it guys!

98

(9 replies, posted in Reports)

Hey report gurus,
.
I'm hoping to solve this without posting a project... because it's a snippet.
.
I am simply trying to hide a (I'm not sure what they're called in Reports) Memo field maybe?

procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
begin
  if Memo1.Value = '00:00' then
    Memo1.Visible := False;                                                                   
end;

.
The field is referencing a DateTime field from the database.  And it is formatted to only show the time as hh:mm.
.
Is there a way to test the contents (for conditional formatting type stuff)?  I have tried Memo1.Value and Memo1.Text... are there any other properties to test for this?
.
Thanks in advance,
-joshuA

Hi prahousefamily,
.
Someone else might be able to help you with the checkbox part.  I have not seen that done before as a tableGrid control-  though I would be curious if this is possible as well.
.
As far as changing the values presented in the tableGrid, this is one way to do it.  Create an extra calculatedField in your table containing this line:

case boolField when 1 then 'aaa' when 0 then 'bbb ' else '' end

.
Changing the boolField to the name of your actual boolean field, and the 'aaa' and 'bbb' to the values corresponding to the 1 and 0.
.
Hope this gets you started,
-joshuA

Hey sparrow,
.
This works nicely, and I appreciate the example.  There are so many tricks- I have so much to learn with MVD!
.
Thanks again to you and derek.