{"id":548,"date":"2019-08-11T00:39:37","date_gmt":"2019-08-11T04:39:37","guid":{"rendered":"http:\/\/regina-whipp.com\/blog\/?p=548"},"modified":"2019-08-11T00:39:37","modified_gmt":"2019-08-11T04:39:37","slug":"wheres-the-cursor","status":"publish","type":"post","link":"https:\/\/regina-whipp.com\/blog\/?p=548","title":{"rendered":"Where&#8217;s the Cursor?"},"content":{"rendered":"<p>When tabbing between Controls on Forms and they contain text all the data within the Control is selected.\u00a0 This can be problematic as Users may inadvertently overwrite what is already there and not even realize it as they begin typing.\u00a0 To avoid that you can force the Cursor to land at the beginning or the end of the Control by using one of\u00a0 the below Sub&#8217;s.\u00a0 For example, for Controls where the Date is entered I prefer to have the User start at the beginning, however, if entering notes I put the Cursor at the end of the Control.<\/p>\n<p>To put the Cursor at the beginning&#8230;<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nSub sMoveCursorToStart()\r\nOn Error GoTo ClearIt\r\n'Moves the cursor to the START of text in the control\r\n\r\n     Dim ctl As Control\r\n     Set ctl = Screen.ActiveControl\r\n     \r\n     If IsNull(ctl) Then Exit Sub\r\n        ctl.SelStart = 0\r\n     Exit Sub\r\n\r\nClearIt:\r\n     Err.Clear\r\nEnd Sub\r\n<\/pre>\n<p>To use place the below in the On_Enter of the Control&#8230;<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nMe!YourControlName.EnterKeyBehavior = True\r\nsMoveCursorToStart\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>To put the Cursor at the end&#8230;<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nSub sMoveCursorToEnd()\r\nOn Error GoTo ClearIt\r\n'Moves the cursor to the END of text in the control\r\n     \r\n     Dim ctl As Control\r\n     Set ctl = Screen.ActiveControl\r\n\r\n     If IsNull(ctl) Then Exit Sub\r\n        ctl.SelStart = Len(ctl.Text)\r\n     Exit Sub\r\n\r\nClearIt:\r\n     Err.Clear\r\nEnd Sub\r\n<\/pre>\n<p>To use place the below in the On_Enter of the Control&#8230;<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nMe!YourControlName.EnterKeyBehavior = True\r\nsMoveCursorToEnd\r\n<\/pre>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_548\" class=\"pvc_stats all  \" data-element-id=\"548\" 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>When tabbing between Controls on Forms and they contain text all the data within the Control is selected. This can be problematic as Users may inadvertently overwrite what is already there and not even realize it as they begin typing. To avoid that you can force the Cursor to land at the beginning or the [&#8230;]<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_548\" class=\"pvc_stats all  \" data-element-id=\"548\" 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":[82,18,21],"class_list":["post-548","post","type-post","status-publish","format-standard","hentry","category-access-tips","category-database-design","tag-controls","tag-database-design","tag-vba","odd"],"_links":{"self":[{"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/548","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=548"}],"version-history":[{"count":9,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/548\/revisions"}],"predecessor-version":[{"id":1390,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/548\/revisions\/1390"}],"wp:attachment":[{"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=548"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=548"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=548"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}