{"id":578,"date":"2013-02-11T02:03:27","date_gmt":"2013-02-11T02:03:27","guid":{"rendered":"http:\/\/regina-whipp.com\/blog\/?p=578"},"modified":"2016-07-08T22:43:20","modified_gmt":"2016-07-09T02:43:20","slug":"sort-using-labels","status":"publish","type":"post","link":"https:\/\/regina-whipp.com\/blog\/?p=578","title":{"rendered":"Sort using Labels&#8230;"},"content":{"rendered":"<p>On continuous forms Users always want to\u00a0Sort and while they could do it from the Toolbar (Access 2003 or lower) or the Ribbon (access 2007 or higher), here&#8217;s another option&#8230;<\/p>\n<p>The two fields we&#8217;re going to use are Date Modified and Import Date.\u00a0 As you can see,\u00a0I\u00a0changed the LABEL\u00a0back color\u00a0to a pale yellow.\u00a0 This is the color I use when the *Sorting* option is available for a specific field\/column.\u00a0 I will also change the TEXT color when sorting which, effectively,\u00a0acts as my trigger.\u00a0 (I also only apply this sorting option to continuous forms.)<\/p>\n<p>To *activate* the Sorting we&#8217;re going to use the On_Click event of the LABEL.\u00a0 You will notice that while sorting on one field you still need to control the other field(s)\/column(s) you&#8217;re srting on just in case your User jumps to sort another field\/column without *releasing* the initial field\/column.\u00a0 We start off with the fields unsorted (Figure 1)&#8230;<\/p>\n<div id=\"attachment_584\" style=\"width: 179px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-584\" class=\"wp-image-584 size-full\" src=\"http:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/02\/Unsorted.png\" alt=\"Figure 1\" width=\"169\" height=\"257\" srcset=\"https:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/02\/Unsorted.png 169w, https:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/02\/Unsorted-98x150.png 98w\" sizes=\"auto, (max-width: 169px) 100vw, 169px\" \/><p id=\"caption-attachment-584\" class=\"wp-caption-text\">Figure 1<\/p><\/div>\n<p>Insert the code on the LABELs On_Click event&#8230;<\/p>\n<p>Private Sub lblDateModified_<strong>Click<\/strong>()<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nMe.txtDateModified.SetFocus\r\n\r\nIf Me.lblDateModified.ForeColor = RGB(0, 0, 0) Then\r\n   DoCmd.RunCommand acCmdSortDescending\r\n   Me.lblDateModified.ForeColor = RGB(102, 0, 204)\r\n   Me.lblDateModified.Caption = &quot;Date&quot; &amp; vbCrLf &amp; &quot;Modified &quot; &amp; Chr(118)\r\n   Me.lblImportDate.ForeColor = RGB(0, 0, 0)\r\n   Me.lblImportDate.Caption = &quot;Import&quot; &amp; vbCrLf &amp; &quot;Date&quot;\r\nElse\r\n   DoCmd.RunCommand acCmdSortAscending\r\n   Me.lblDateModified.ForeColor = RGB(0, 0, 0)\r\n   Me.lblDateModified.Caption = &quot;Date&quot; &amp; vbCrLf &amp; &quot;Modified &quot; &amp; Chr(94)\r\n   Me.lblImportDate.ForeColor = RGB(0, 0, 0)\r\n   Me.lblImportDate.Caption = &quot;Import&quot; &amp; vbCrLf &amp; &quot;Date&quot;\r\nEnd If\r\n<\/pre>\n<p>End Sub<\/p>\n<p>The first Click Sorts ascending (Figure 2), leaving the TEXT black&#8230;<\/p>\n<div id=\"attachment_586\" style=\"width: 180px\" class=\"wp-caption alignleft\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-586\" class=\"wp-image-586 size-full\" src=\"http:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/02\/SortAscending.png\" alt=\"SortAscending\" width=\"170\" height=\"383\" srcset=\"https:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/02\/SortAscending.png 170w, https:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/02\/SortAscending-133x300.png 133w, https:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/02\/SortAscending-66x150.png 66w\" sizes=\"auto, (max-width: 170px) 100vw, 170px\" \/><p id=\"caption-attachment-586\" class=\"wp-caption-text\">Figure 2<\/p><\/div>\n<p>The second Click sorts descending (Figure 3), turning the TEXT purple&#8230;<\/p>\n<div id=\"attachment_585\" style=\"width: 179px\" class=\"wp-caption alignleft\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-585\" class=\"wp-image-585 size-full\" src=\"http:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/02\/SortDescending.png\" alt=\"SortDescending\" width=\"169\" height=\"318\" srcset=\"https:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/02\/SortDescending.png 169w, https:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/02\/SortDescending-159x300.png 159w, https:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/02\/SortDescending-79x150.png 79w\" sizes=\"auto, (max-width: 169px) 100vw, 169px\" \/><p id=\"caption-attachment-585\" class=\"wp-caption-text\">Figure 3<\/p><\/div>\n<p>&nbsp;<\/p>\n<p>&#8230;and because each Click is a *trigger*, so to speak, they will go back and forth (ascending and descending) with each Click with the Import Date remaining UNsorted.\u00a0 To return the Date Imported\u00a0to it&#8217;s\u00a0UNsorted state, double-click the LABEL.\u00a0 But before you do that, don&#8217;t forget to insert the code on the LABELs DoubleClick event&#8230;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<div id=\"attachment_584\" style=\"width: 179px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-584\" class=\"wp-image-584 size-full\" src=\"http:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/02\/Unsorted.png\" alt=\"Figure 1\" width=\"169\" height=\"257\" srcset=\"https:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/02\/Unsorted.png 169w, https:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/02\/Unsorted-98x150.png 98w\" sizes=\"auto, (max-width: 169px) 100vw, 169px\" \/><p id=\"caption-attachment-584\" class=\"wp-caption-text\">Figure 1<\/p><\/div>\n<p>Private Sub lblDateModified_<strong>DblClick<\/strong>(Cancel As Integer)<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n   Me.OrderByOn = False\r\n   Me.OrderBy = vbNullString\r\n   Me.lblDateModified.Caption = &quot;Date&quot; &amp; vbCrLf &amp; &quot;Modified&quot;\r\n   Me.lblDateModified.ForeColor = RGB(0, 0, 0)\r\n   Me.txtDateModified.SetFocus\r\n<\/pre>\n<p>End Sub<\/p>\n<p>And here&#8217;s the code for the lblImportDate&#8217;s (Figure 4) Click and Double_Click events&#8230;<\/p>\n<div id=\"attachment_587\" style=\"width: 180px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-587\" class=\"wp-image-587 size-full\" src=\"http:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/02\/SortAscendingImportDate.png\" alt=\"SortAscendingImportDate\" width=\"170\" height=\"361\" srcset=\"https:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/02\/SortAscendingImportDate.png 170w, https:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/02\/SortAscendingImportDate-141x300.png 141w, https:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/02\/SortAscendingImportDate-70x150.png 70w\" sizes=\"auto, (max-width: 170px) 100vw, 170px\" \/><p id=\"caption-attachment-587\" class=\"wp-caption-text\">Figure 4<\/p><\/div>\n<p>Private Sub lblImportDate_<strong>Click<\/strong>()<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n   Me.txtImportDate.SetFocus\r\n\r\nIf Me.lblImportDate.ForeColor = RGB(0, 0, 0) Then\r\n   DoCmd.RunCommand acCmdSortDescending\r\n   Me.lblImportDate.ForeColor = RGB(102, 0, 204)\r\n   Me.lblImportDate.Caption = &quot;Import&quot; &amp; vbCrLf &amp; &quot;Date &quot; &amp; Chr(118)\r\n   Me.lblDateModified.Caption = &quot;Date&quot; &amp; vbCrLf &amp; &quot;Modified&quot;\r\n   Me.lblDateModified.ForeColor = RGB(0, 0, 0)\r\nElse\r\n   DoCmd.RunCommand acCmdSortAscending\r\n   Me.lblImportDate.ForeColor = RGB(0, 0, 0)\r\n   Me.lblImportDate.Caption = &quot;Import&quot; &amp; vbCrLf &amp; &quot;Date &quot; &amp; Chr(94)\r\n   Me.lblDateModified.Caption = &quot;Date&quot; &amp; vbCrLf &amp; &quot;Modified&quot;\r\n   Me.lblDateModified.ForeColor = RGB(0, 0, 0)\r\nEnd If\r\n<\/pre>\n<p>End Sub<\/p>\n<p>Private Sub lblImportDate_<strong>DblClick<\/strong>(Cancel As Integer)<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n   Me.OrderByOn = False\r\n   Me.OrderBy = vbNullString\r\n   Me.lblImportDate.ForeColor = RGB(0, 0, 0)\r\n   Me.lblImportDate.Caption = &quot;Import&quot; &amp; vbCrLf &amp; &quot;Date&quot;\r\n   Me.txtImportDate.SetFocus\r\n<\/pre>\n<p>End Sub<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_578\" class=\"pvc_stats all  \" data-element-id=\"578\" 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>On continuous forms Users always want to Sort and while they could do it from the Toolbar (Access 2003 or lower) or the Ribbon (access 2007 or higher), here&#8217;s another option&#8230;<\/p>\n<p>The two fields we&#8217;re going to use are Date Modified and Import Date. As you can see, I changed the LABEL back color to [&#8230;]<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_578\" class=\"pvc_stats all  \" data-element-id=\"578\" 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":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,63],"tags":[64,31,21],"class_list":["post-578","post","type-post","status-publish","format-standard","hentry","category-access-tips","category-database-design","tag-access-tips","tag-forms","tag-vba","odd"],"_links":{"self":[{"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/578","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=578"}],"version-history":[{"count":42,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/578\/revisions"}],"predecessor-version":[{"id":1272,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/578\/revisions\/1272"}],"wp:attachment":[{"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=578"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=578"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=578"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}