{"id":1227,"date":"2016-07-11T01:08:08","date_gmt":"2016-07-11T05:08:08","guid":{"rendered":"http:\/\/regina-whipp.com\/blog\/?p=1227"},"modified":"2019-11-17T19:35:54","modified_gmt":"2019-11-18T00:35:54","slug":"reminder","status":"publish","type":"post","link":"https:\/\/regina-whipp.com\/blog\/?p=1227","title":{"rendered":"Conditional Image on a Continuous Form (Reminders)&#8230;"},"content":{"rendered":"<p>Since Microsoft Access 2007 getting a different Image to show up for each record is pretty easy, you just need to bind the Image Control to the field that holds the path to the image and you are done. However, I wanted a conditional image on my Continuous Form based on whether there was a Reminder set\u2026 hmm.<\/p>\n<p>Continuous Forms are great for listing things like Tasks or Orders even Customers but how to show a Reminder for a particular Order? You know something extra to be done when processing the Customer\u2019s Order.\u00a0 Putting that information under Order Notes doesn\u2019t really help because you\u2019re dependent on remembering to open the notes and then sift thru them to find the important one\u2026 odds are that\u2019s not going to happen.<\/p>\n<p>So, let\u2019s create a Reminder\u2026<\/p>\n<p>For this example, we are going to be using Orders on the Order Details side. (Don\u2019t forget to change Field Names to match the ones in your database!)\u00a0 Whichever Table you decide to use it MUST have a Primary Key and in this example, it MUST be NUMERIC.\u00a0 If you are using TEXT as a Data Type for your Primary Key, all code will need to be adjusted accordingly.<\/p>\n<h6>Step 1<\/h6>\n<p>To your table add two fields\u2026<\/p>\n<p><span style=\"color: #999999;\">tblOrderDetails (My Table)<\/span><br \/>\n<strong>odReminder<\/strong> (Yes\/No)<br \/>\n<strong>odReminderImagePath<\/strong> (Text, 255 or Short Text)<\/p>\n<h6>Step 2<\/h6>\n<p>Add <strong>tblReminders<\/strong> with the fields listed below\u2026<\/p>\n<p><strong>rReminderID<\/strong> (Primary Key, Autonumber)<br \/>\n<strong>rID<\/strong> (Number, Long Integer) \u2013 This will hold the Primary Key for whichever Table(s) you are using the Reminders with.<br \/>\n<strong>rReminder<\/strong> (Memo, Rich Text or Long Text, Rich Text)<br \/>\n<strong>rShow<\/strong> (Yes\/No)<br \/>\n<strong>rDate<\/strong> (Date\/Time) \u2013 optional, if you want to know when the reminder was created<br \/>\n<strong>rNetworkID<\/strong> (Text, 50 or Short Text) \u2013 optional, if you want to know who created the reminder<br \/>\n<strong>rSystemForm<\/strong> (Text, 50 or Short Text) \u2013 This will only be needed if you plan to use the Reminder in multiple areas, such as, Orders and Tasks.<\/p>\n<h6>Step 3<\/h6>\n<p>Find two images, one for ON and one for OFF and place them in a shared folder on the Network preferably in a sub directory of the Backend, i.e. ServerLetter:\\DirectoryName\\Images. You will also need them on your Command Buttons on Step 4.\u00a0 (<span style=\"color: #808080;\">To put a custom image on a Command Button click <a style=\"color: #808080;\" href=\"http:\/\/access-diva.com\/blog\/?p=325\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.<\/span>)\u00a0 My favorite place to find images is <a href=\"http:\/\/www.iconarchive.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Icon Archive<\/a>.<\/p>\n<h6>Step 4<\/h6>\n<p>Create your Reminder Form\u2026<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-956\" src=\"http:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2016\/07\/reminderDesign.png\" alt=\"reminderDesign\" width=\"409\" height=\"564\" \/><\/p>\n<p>Set the Recordsource for your Form:<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">SELECT tblReminders.rReminderID, tblReminders.rID, tblReminders.rReminder, tblReminders.rShow, tblOrderDetails.odReminder, tblOrderDetails.odReminderImagePath FROM tblOrderDetails INNER JOIN tblReminders ON tblOrderDetails.odOrderDetailID = tblReminders.rID;<\/pre>\n<p>Then place two <strong>Command Buttons<\/strong> on your Form in the <strong>Form Header<\/strong> section, one with the ON image named <strong>cmdOn<\/strong> and the other with the OFF image named <strong>cmdOff<\/strong> and place them on top of each other.<\/p>\n<p>Then add an UNBOUND Text Control named <strong>txtFocus<\/strong> and place it in the <strong>Form Header<\/strong>, see the purple oval. Also, set it as the <strong>first Tab Stop<\/strong> and leave it <strong>Visible<\/strong>.<\/p>\n<p>Add the other <strong>Controls<\/strong> (use <a href=\"http:\/\/www.access-diva.com\/d1.html\" target=\"_blank\" rel=\"noopener noreferrer\">Naming Conventions<\/a> to correspond to the below or the code will not work, i.e. txtID, chkShow, etc.) in the <strong>Detail<\/strong> section and hide, Visible = No, \u00a0except for the <strong>rReminder<\/strong> which is where the reminder will be entered. This is a one-to-one so make sure your <strong>Form<\/strong> is set as a <strong>Single Form<\/strong>.<\/p>\n<p>In the Forms On_Load Event Procedure place&#8230;<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">    If Me!chkShow = False Then\r\n        Me!cmdOff.Visible = True\r\n        Me.cmdOn.Visible = False\r\n    Else\r\n        Me!cmdOff.Visible = False\r\n        Me.cmdOn.Visible = True\r\n    End If\r\n<\/pre>\n<p>In the On_Click Event Procedure of the two Command Buttons cmdOn and cmdOff place (Yes, they it is the same code for both buttons.)\u2026<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">    If Me!chkShow = False Then\r\n        Me.chkShow = True\r\n        Me.txtFocus.SetFocus\r\n        Me!cmdOff.Visible = False\r\n        Me.cmdOn.Visible = True\r\n        Me.chkReminder = True\r\n        Me.txtReminderImagePath = &quot;Full Path to YOUR image goes here!&quot;\r\n        \u2018Toggle the Command Buttons on the Order Details Form\r\n        Forms!&#x5B;frmOrders]!&#x5B;sfrOrderDetails].Form!&#x5B;txtFocus].SetFocus\r\n        Forms!&#x5B;frmOrders]!&#x5B;sfrOrderDetails].Form!&#x5B;cmdOff].Visible = False\r\n        Forms!&#x5B;frmOrders]!&#x5B;sfrOrderDetails].Form!&#x5B;cmdOn].Visible = True\r\n    Else\r\n        Me.chkShow = False\r\n        Me.txtFocus.SetFocus\r\n        Me!cmdOff.Visible = True\r\n        Me.cmdOn.Visible = False\r\n        Me.chkReminder = True\r\n        Me.txtReminderImagePath = &quot;&quot;\r\n        \u2018Toggle the Command Buttons on the Order Details Form\r\n        Forms!&#x5B;frmOrders]!&#x5B;sfrOrderDetails].Form!&#x5B;txtFocus].SetFocus\r\n        Forms!&#x5B;frmOrders]!&#x5B;sfrOrderDetails].Form!&#x5B;cmdOff].Visible = True\r\n        Forms!&#x5B;frmOrders]!&#x5B;sfrOrderDetails].Form!&#x5B;cmdOn].Visible = False\r\n    End If\r\n<\/pre>\n<p>Set the Form as a Pop Up, then save, and close. (Oh, you probably want to take a peek first!)<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-956\" src=\"http:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2016\/07\/reminder.png\" alt=\"reminder\" width=\"364\" height=\"465\" \/><\/p>\n<p>Side note: While I added Spell Check, an Eraser and a Close button to mine they are not needed to make this work, so, consider those optional.<\/p>\n<h6>Step 5<\/h6>\n<p>Open your <strong>Orders\/Order Details Form<\/strong> in<strong> Design Mode<\/strong> and on the <strong>Order Details Subform<\/strong> (many side) add two<strong> Command Buttons<\/strong> on your <strong>Form<\/strong>, one with the ON image named <strong>cmdOn<\/strong> and the other with the OFF image named <strong>cmdOff<\/strong> and place them on top of each other.<\/p>\n<p>Then add an <strong>UNBOUND Text Control<\/strong> to the <strong>Details<\/strong> section named <strong>txtFocus<\/strong> and leave it <strong>Visible<\/strong>.<\/p>\n<h6>Step 6<\/h6>\n<p>Let\u2019s add the code\u2026<\/p>\n<p>In the <strong>On_Click Event Procedure<\/strong> of <strong>cmdOn<\/strong> and <strong>cmdOff<\/strong> place\u2026<\/p>\n<p><strong>cmdOff<\/strong><\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">On Error GoTo Err_cmdOff_Click\r\n\r\n    DoCmd.OpenForm &quot;sfrReminder&quot;, , , &quot;&#x5B;rID] = &quot; &amp; Me!&#x5B;txtOrderDetailID] &amp; &quot; And rSystemForm Like &quot;&quot;*order*&quot;&quot;&quot;\r\n    Forms!&#x5B;sfrReminder]!&#x5B;txtID] = Me.txtOrderDetailID\r\n    Forms!&#x5B;sfrReminder]!&#x5B;txtSystemForm] = \u201cfrmOrders\u201d\r\n    Forms!&#x5B;sfrReminder].Caption = &quot;Order Reminder\r\n\r\nExit_cmdOff_Click:\r\n    Exit Sub\r\n\r\nErr_cmdOff_Click:\r\n    MsgBox Err.Description\r\n    Resume Exit_cmdOff_Click\r\n<\/pre>\n<p><strong>cmdOn<\/strong><\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">On Error GoTo Err_cmdOn_Click\r\n\r\n    DoCmd.OpenForm &quot;sfrReminder&quot;, , , &quot;&#x5B;rID] = &quot; &amp; Me!&#x5B;txtOrderDetailID] &amp; &quot; And rSystemForm Like &quot;&quot;*order*&quot;&quot;&quot;\r\n    Forms!&#x5B;sfrReminder]!&#x5B;txtID] = Me.txtOrderDetailID\r\n    Forms!&#x5B;sfrReminder]!&#x5B;txtSystemForm] = \u201cfrmOrders\u201d\r\n    Forms!&#x5B;sfrReminder].Caption = &quot;Order Reminder\r\n\r\nExit_cmdOn_Click:\r\n    Exit Sub\r\n\r\nErr_cmdOn_Click:\r\n    MsgBox Err.Description\r\n    Resume Exit_cmdOn_Click\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>In the <strong>Forms On_Current Event Procedure<\/strong> place\u2026<br \/>\n<span style=\"color: #c43131;\"><strong>IMPORTANT<\/strong><\/span>: Because there is an *<strong>Exit Sub<\/strong>* in this routine you want to make sure to put this at the end of any other events you have running so it does not exit prematurely.<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">    Dim bnReminder As Boolean\r\n\r\n    If DCount(&quot;rID&quot;, &quot;tblReminders&quot;, &quot;&#x5B;rID] = &quot; &amp; Me!&#x5B;txtOrderDetailID] &amp; &quot; And rSystemForm Like &quot;&quot;*order*&quot;&quot;&quot;) = 0 Then\r\n    Me!cmdOff.Visible = True\r\n    Me.cmdOn.Visible = False\r\n    Exit Sub\r\n    End If\r\n\r\n    bnReminder = DLookup(&quot;rShow&quot;, &quot;tblReminders&quot;, &quot;&#x5B;rID] = &quot; &amp; Me!&#x5B;txtOrderDetailID] &amp; &quot; And rSystemForm Like &quot;&quot;*order*&quot;&quot;&quot;)\r\n\r\n    If bnReminder = False Then\r\n        Me!cmdOff.Visible = True\r\n        Me.cmdOn.Visible = False\r\n    Else\r\n        Me!cmdOff.Visible = False\r\n        Me.cmdOn.Visible = True\r\n    End If\r\n<\/pre>\n<p>Then save and close. (Don\u2019t worry, we\u2019re almost there\u2026)<\/p>\n<h6>Step 7<\/h6>\n<p>Open the<strong> Continuous Form<\/strong> with the Orders and add <strong>odReminder<\/strong> and <strong>odReminderImagePath<\/strong> to the <strong>Recordsource<\/strong>. Then, on the Form add a Command Button, <strong>cmdReminder<\/strong>, and make it <strong>Transparent<\/strong> and change the <strong>Cursor on Hover<\/strong> to <strong>Hyperlink Hand<\/strong>. (Note, you can simply use the On_Click event of the Image Control if you\u2019re not concerned about the Hyperlink Hand, I just like the little hand!)<\/p>\n<p>Then add an <strong>Image Control<\/strong> named <strong>imgReminder<\/strong> and set the <strong>Control Source<\/strong> as <strong>odReminderImagePath<\/strong>. Place the <strong>Command Button<\/strong> on top of the<strong> Image Control<\/strong>. Finally, place a <strong>Check Box<\/strong> with a<strong> Control Source<\/strong> of <strong>odReminder<\/strong> and set <strong>Visible<\/strong> to <strong>No<\/strong> and <strong>Tab Stop<\/strong> to <strong>No<\/strong>.<\/p>\n<p>In the<strong> Command Button cmdReminder\u2019s On_Click Event Procedure<\/strong> place\u2026<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">    If Me.chkReminder = True Then\r\n        DoCmd.OpenForm &quot;sfrReminder&quot;, , , &quot;&#x5B;rID] = &quot; &amp; Me!&#x5B;txtOrderDetailID] &amp; &quot; And rSystemForm Like &quot;&quot;*order*&quot;&quot;&quot;\r\n        Forms!&#x5B;sfrReminder].Caption = &quot;Order Reminder\r\n    Else\r\n        DoCmd.CancelEvent\r\n    End If\r\n<\/pre>\n<p>All done!<\/p>\n<p>Now, once a Reminder has been set from the Orders Form it will show on the Continuous Form&#8230;<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-956\" src=\"http:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2016\/07\/ContinuousForm.png\" alt=\"ContinuousForm\" width=\"336\" height=\"156\" \/>To use, from the Orders Form click the little alarm to open the Reminder Form, type your reminder and click the little alarm to turn it on and close.<\/p>\n<p>In case you&#8217;re interested&#8230; This works because each record has a field for the image.\u00a0 If there is no reminder we remove the path and since the Image Control for each record is bound\u00a0rReminderImagePath, nothing will show if there is no path entered.<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_1227\" class=\"pvc_stats all  \" data-element-id=\"1227\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/regina-whipp.com\/blog\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Since Microsoft Access 2007 getting a different Image to show up for each record is pretty easy, you just need to bind the Image Control to the field that holds the path to the image and you are done. However, I wanted a conditional image on my Continuous Form based on whether there was a [&#8230;]<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_1227\" class=\"pvc_stats all  \" data-element-id=\"1227\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/regina-whipp.com\/blog\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,63],"tags":[41,18,31,46,80],"class_list":["post-1227","post","type-post","status-publish","format-standard","hentry","category-access-tips","category-database-design","tag-continuous-forms","tag-database-design","tag-forms","tag-image-handling","tag-reminders","odd"],"a3_pvc":{"activated":true,"total_views":2297,"today_views":0},"_links":{"self":[{"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1227","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1227"}],"version-history":[{"count":19,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1227\/revisions"}],"predecessor-version":[{"id":1408,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1227\/revisions\/1408"}],"wp:attachment":[{"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}