<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[My Visual Database — Put today's date in DateAdded column]]></title>
		<link>https://myvisualdatabase.com/forum/viewtopic.php?id=7178</link>
		<atom:link href="https://myvisualdatabase.com/forum/extern.php?action=feed&amp;tid=7178&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Put today's date in DateAdded column.]]></description>
		<lastBuildDate>Thu, 10 Dec 2020 14:29:04 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Put today's date in DateAdded column]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=39309#p39309</link>
			<description><![CDATA[<p>Derek,<br />Thanks<br />Alan</p>]]></description>
			<author><![CDATA[null@example.com (asawyer13)]]></author>
			<pubDate>Thu, 10 Dec 2020 14:29:04 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=39309#p39309</guid>
		</item>
		<item>
			<title><![CDATA[Re: Put today's date in DateAdded column]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=39308#p39308</link>
			<description><![CDATA[<p>Hi Brian, Alan,<br />Another option would be as per the attached (it&#039;s a simple modification of something I use to check for duplicate records).<br />It allows you to test as many fields as you want for any changes to one or any number of them.<br />If there are no changes and even if &#039;save&#039; is clicked, the &#039;modified date&#039; is not altered.&nbsp; <br />If there are changes and &#039;save&#039; is clicked, then the &#039;modified date&#039; of the record is updated with the current date.&nbsp; <br />New records are simply added with a &#039;creation date&#039; of the current date and the &#039;modified date&#039; is left blank.<br />Can&#039;t think of any other way (but there probably are).<br />Derek.</p>]]></description>
			<author><![CDATA[null@example.com (derek)]]></author>
			<pubDate>Thu, 10 Dec 2020 12:29:38 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=39308#p39308</guid>
		</item>
		<item>
			<title><![CDATA[Re: Put today's date in DateAdded column]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=39302#p39302</link>
			<description><![CDATA[<div class="quotebox"><cite>asawyer13 wrote:</cite><blockquote><p>If I do this on the OnClick event, I believe I get the right info.</p><p>Will test some more</p></blockquote></div><p>My Bad. I wasn&#039;t on my mind when I suggest that. LMAO, I updated my first reply. Stick to OnAfterClick event for it must be saved first. Anyway, I think derek&#039;s solutions is an awesome solution. Having many fields to check will require you to add additional components but I think it is the best solution. Anyway, if you really want to have it on after click even the user didn&#039;t change any record, here I modified derek&#039;s solution.</p>]]></description>
			<author><![CDATA[null@example.com (brian.zaballa)]]></author>
			<pubDate>Thu, 10 Dec 2020 04:04:13 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=39302#p39302</guid>
		</item>
		<item>
			<title><![CDATA[Re: Put today's date in DateAdded column]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=39301#p39301</link>
			<description><![CDATA[<p>If I do this on the OnClick event, I believe I get the right info.</p><p>Will test some more</p>]]></description>
			<author><![CDATA[null@example.com (asawyer13)]]></author>
			<pubDate>Thu, 10 Dec 2020 02:00:39 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=39301#p39301</guid>
		</item>
		<item>
			<title><![CDATA[Re: Put today's date in DateAdded column]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=39300#p39300</link>
			<description><![CDATA[<div class="quotebox"><cite>asawyer13 wrote:</cite><blockquote><p>Derek,<br />If I don&#039;t want to go to the work of adding extra fields to tell if the actual values have changed, and just want to update modified date if they click save, but only if it&#039;s not a new record, how could I do this?</p><div class="codebox"><pre><code>procedure frmMedications_Button5_OnAfterClick (Sender: TObject);
begin
        If Action &lt;&gt; &#039;NewRecord&#039;  then
        Begin
            SQLExecute(&#039;Update Medications set ModifiedDate = CurDate() Where ID = &#039; + frmPerson.tablegrid1.sqlvalue );
        End;
end;</code></pre></div><p>I tried this but either have a typo or something in it.</p></blockquote></div><p>I can think of 2 solutions:<br />1. Have a global boolean variable e.g. IsANewRecord and set its value on the OnShow of frmMedications</p><div class="codebox"><pre><code>IsANewRecord = (Action = &#039;NewRecord&#039;);</code></pre></div><p>2. Set frmMedications.Tag in the OnShow of the form</p><div class="codebox"><pre><code>if Action = &#039;NewRecord&#039; then
    frmMedications.Tag = 0
else
    frmMedications.Tag = 1;</code></pre></div><p>Then, change </p><div class="codebox"><pre><code>If Action &lt;&gt; &#039;NewRecord&#039;  then</code></pre></div><p>to<br />case 1:</p><div class="codebox"><pre><code>if Not IsANewRecord then</code></pre></div><p>case 2:</p><div class="codebox"><pre><code>if frmMedications.Tag=1 then</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (brian.zaballa)]]></author>
			<pubDate>Thu, 10 Dec 2020 01:59:41 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=39300#p39300</guid>
		</item>
		<item>
			<title><![CDATA[Re: Put today's date in DateAdded column]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=39299#p39299</link>
			<description><![CDATA[<p>I tried this also but that didn&#039;t work either..</p><p>It seems to update the modified date on adds.</p><div class="codebox"><pre><code>begin
        If frmMedications.dbAction &lt;&gt; &#039;NewRecord&#039;   then
        Begin
            SQLExecute(&#039;Update Medications set ModifiedDate = CurDate() Where ID = &#039; + frmPerson.tablegrid1.sqlvalue );
        End;
end;</code></pre></div><p>Looks like the value of dbAction is &#039;SaveRecord&#039;<br />But it&#039;s SaveRecord on the add of new and also the save of the modify.</p><p>Obviously I&#039;m confused.</p>]]></description>
			<author><![CDATA[null@example.com (asawyer13)]]></author>
			<pubDate>Thu, 10 Dec 2020 01:55:58 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=39299#p39299</guid>
		</item>
		<item>
			<title><![CDATA[Re: Put today's date in DateAdded column]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=39298#p39298</link>
			<description><![CDATA[<p>Derek,<br />If I don&#039;t want to go to the work of adding extra fields to tell if the actual values have changed, and just want to update modified date if they click save, but only if it&#039;s not a new record, how could I do this?</p><div class="codebox"><pre><code>procedure frmMedications_Button5_OnAfterClick (Sender: TObject);
begin
        If Action &lt;&gt; &#039;NewRecord&#039;  then
        Begin
            SQLExecute(&#039;Update Medications set ModifiedDate = CurDate() Where ID = &#039; + frmPerson.tablegrid1.sqlvalue );
        End;
end;</code></pre></div><p>I tried this but either have a typo or something in it.</p>]]></description>
			<author><![CDATA[null@example.com (asawyer13)]]></author>
			<pubDate>Thu, 10 Dec 2020 01:43:53 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=39298#p39298</guid>
		</item>
		<item>
			<title><![CDATA[Re: Put today's date in DateAdded column]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=39297#p39297</link>
			<description><![CDATA[<p>Try it like this (see attached), but there are other ways as well.<br />The &#039;date added &#039;takes care of itself - set &#039;default checked&#039; and &#039;checked&#039; to be true in the &#039;date added&#039; properties of the datetimepicker object so that it always uses the current date.<br />The &#039;date modified&#039; stays blank if the record has only been created.<br />The &#039;date modified&#039; is updated with the current date if the record is changed.<br />The &#039;date modified&#039; is not updated if the record is viewed but not changed.<br />The &#039;save&#039; button is made visible only when a new record is created or when a change has been made.<br />Derek.</p>]]></description>
			<author><![CDATA[null@example.com (derek)]]></author>
			<pubDate>Thu, 10 Dec 2020 00:52:59 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=39297#p39297</guid>
		</item>
		<item>
			<title><![CDATA[Re: Put today's date in DateAdded column]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=39294#p39294</link>
			<description><![CDATA[<p>This is what I have so far.</p><p>I was trying to load today&#039;s date to test, but trying to get it to be automatic.</p><div class="codebox"><pre><code>   frmmPerson.dtDateAdded.sqlDate := &#039;2020-12-09&#039;; //strftime(&#039;%Y-%M-%D&#039;,DATE(&#039;now&#039;));</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (asawyer13)]]></author>
			<pubDate>Wed, 09 Dec 2020 21:59:14 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=39294#p39294</guid>
		</item>
		<item>
			<title><![CDATA[Put today's date in DateAdded column]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=39292#p39292</link>
			<description><![CDATA[<p>I have a field called DateAdded in my Person table.</p><p>When I&#039;m adding a new record what&#039;s the best way to load todays date into the field so it&#039;s there when I save the record?</p><p>Also if I want to do the same thing with a DataModified field when the user modifies the record.</p><p>I&#039;ve tried searching but just not quite seeing how to do it.</p><p>Alan</p>]]></description>
			<author><![CDATA[null@example.com (asawyer13)]]></author>
			<pubDate>Wed, 09 Dec 2020 21:10:22 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=39292#p39292</guid>
		</item>
	</channel>
</rss>
