{"id":785,"date":"2013-08-16T01:23:08","date_gmt":"2013-08-16T01:23:08","guid":{"rendered":"http:\/\/regina-whipp.com\/blog\/?p=785"},"modified":"2016-07-08T22:52:39","modified_gmt":"2016-07-09T02:52:39","slug":"combo-box-to-find-records","status":"publish","type":"post","link":"https:\/\/regina-whipp.com\/blog\/?p=785","title":{"rendered":"Combo Box to Find Records&#8230;"},"content":{"rendered":"<p>You want\u00a0your Users to be able to\u00a0look up and\/or add new\u00a0activities for existing Companies but they may not know or remember the Company Name but they do remember the person they speak to on a daily basis.\u00a0 Well,\u00a0you don&#8217;t want to add a separate Combo Box for Company Name, First Name, etc.\u00a0\u00a0Depending on how many fields you want to use putting that many Combo Boxes on a\u00a0Form can get a bit crowded.\u00a0\u00a0 In this example, you will only need two Combo Boxes on your Main form&#8230;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-788 size-full\" src=\"http:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/08\/frmComboBox.png\" alt=\"frmComboBox\" width=\"534\" height=\"384\" srcset=\"https:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/08\/frmComboBox.png 534w, https:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/08\/frmComboBox-300x215.png 300w, https:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/08\/frmComboBox-150x107.png 150w, https:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/08\/frmComboBox-400x287.png 400w\" sizes=\"auto, (max-width: 534px) 100vw, 534px\" \/><\/p>\n<h5>Step 1<\/h5>\n<p>On your Main Form add two Combo Boxes.\u00a0 In my example, I named them <span style=\"color: #0000ff;\">cboSearch<\/span> (top one) \u00a0and <span style=\"color: #008000;\">cboResults<\/span> (bottom one).\u00a0\u00a0 For your Subform use the table that holds the Activities for your Contacts.\u00a0 (Note:\u00a0 You can also use this set up to search for Vendor Products, Service Calls, Work Orders, and so on.)<\/p>\n<p><span style=\"color: #0000ff;\"><strong>cboSearch<\/strong><\/span><br \/>\nIn the Properties window&#8230;<\/p>\n<p><span style=\"color: #000080;\"><strong>On the Data tab&#8230;<\/strong><\/span><br \/>\nRow Source = 1;Company Name;2;Last Name;3;First Name;4;eMail Address<br \/>\nRow Source Type = Value List<br \/>\nBound Column = 1<\/p>\n<p><strong><span style=\"color: #000080;\">On the Format tab&#8230;<\/span><\/strong><br \/>\nColumn Count = 2<br \/>\nColumn Widths = 0&#8243;;1&#8243;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-786 size-full\" src=\"http:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/08\/ComboBox.png\" alt=\"ComboBox\" width=\"534\" height=\"384\" srcset=\"https:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/08\/ComboBox.png 534w, https:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/08\/ComboBox-300x215.png 300w, https:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/08\/ComboBox-150x107.png 150w, https:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2013\/08\/ComboBox-400x287.png 400w\" sizes=\"auto, (max-width: 534px) 100vw, 534px\" \/><\/p>\n<p><span style=\"color: #000080;\"><span style=\"color: #333333;\"><strong><span style=\"color: #008000;\">cboResults<\/span><\/strong><br \/>\nIn the Properties window&#8230;<\/span><\/span><\/p>\n<p><span style=\"color: #000080;\"><strong>On the Data tab&#8230;<\/strong><\/span><br \/>\nRow Source = Leave Blank<br \/>\nRow Source Type = Table\/Query<br \/>\nBound Column = 1<\/p>\n<p><span style=\"color: #000080;\"><strong>On the Format tab&#8230;<\/strong><\/span><br \/>\nColumn Count = 2<br \/>\nColumn Widths = 0&#8243;;1&#8243;<\/p>\n<h5>Step 2<\/h5>\n<p>Create a Query for each Value you want to search by.\u00a0 (Be sure to to put <strong>Is Not Null<\/strong> on the Criteria line of the Company, First Name, etc. so you don&#8217;t get blanks in your Combo Box.)\u00a0 For this example&#8230;<\/p>\n<p><span style=\"color: #993300;\">qrySearchCompany<\/span><br \/>\nqrySearchFirstName<br \/>\nqrySearchLastName<br \/>\nqrySearcheMailAddress<\/p>\n<p><strong>Note:<\/strong>\u00a0 The only thing that is constant throughout the Queries is <strong>first field <span style=\"color: #cc0000;\">must<\/span><\/strong> be the key you are going to link the Main Form and Subform together on.\u00a0\u00a0For example, we care using the <strong><span style=\"color: #cc0000;\">cContactID<\/span><\/strong>, so the Query for <span style=\"color: #993300;\">qrySearchCompany<\/span> would be&#8230;<\/p>\n<p>SELECT tblContacts<strong>.<span style=\"color: #cc0000;\">cContactID<\/span><\/strong>, tblContacts.cCompany<br \/>\nFROM tblContacts<br \/>\nWHERE (((tblContacts.cCompany) Is Not Null));<\/p>\n<h5>Step 3<\/h5>\n<p>In the <strong>After_Update<\/strong> event of\u00a0<span style=\"color: #0000ff;\">cboSearch <span style=\"color: #000000;\">copy\/paste the below (providing you used the same names.\u00a0 If not adjust accordingly)<\/span><\/span><span style=\"color: #000000;\">&#8230;<\/span><\/p>\n<p>Select Case cboSearch<br \/>\nCase 1<br \/>\nMe.cboResults.RowSource = &#8220;qrySearchCompany&#8221;<br \/>\nMe.cboResults = &#8220;&#8221;<br \/>\nMe.sfrActivities.LinkMasterFields = &#8220;cboResults&#8221;<br \/>\nMe.sfrActivities.LinkChildFields = &#8220;aContactID&#8221;<br \/>\nCase 2<br \/>\nMe.cboResults.RowSource = &#8220;qrySearchLastName&#8221;<br \/>\nMe.cboResults = &#8220;&#8221;<br \/>\nMe.sfrActivities.LinkMasterFields = &#8220;cboResults&#8221;<br \/>\nMe.sfrActivities.LinkChildFields = &#8220;aContactID&#8221;<br \/>\nCase 3<br \/>\nMe.cboResults.RowSource = &#8220;qrySearchFirstName&#8221;<br \/>\nMe.cboResults = &#8220;&#8221;<br \/>\nMe.sfrActivities.LinkMasterFields = &#8220;cboResults&#8221;<br \/>\nMe.sfrActivities.LinkChildFields = &#8220;aContactID&#8221;<br \/>\nCase 4<br \/>\nMe.cboResults.RowSource = &#8220;qrySearcheMailAddress&#8221;<br \/>\nMe.cboResults = &#8220;&#8221;<br \/>\nMe.sfrActivities.LinkMasterFields = &#8220;cboResults&#8221;<br \/>\nMe.sfrActivities.LinkChildFields = &#8220;aContactID&#8221;<br \/>\nCase Else<br \/>\nMe.cboResults.RowSource = &#8220;&#8221;<br \/>\nMe.cboResults = &#8220;&#8221;<br \/>\nMe.sfrActivities.LinkMasterFields = &#8220;&#8221;<br \/>\nMe.sfrActivities.LinkChildFields = &#8220;&#8221;<br \/>\nEnd Select<\/p>\n<h5>All done&#8230; Enjoy!<\/h5>\n<p>You can download a sample <a href=\"http:\/\/www.access-diva.com\/myzipfiles\/ComboBox.zip\" target=\"_blank\">here<\/a>.<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_785\" class=\"pvc_stats all  \" data-element-id=\"785\" 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>You want your Users to be able to look up and\/or add new activities for existing Companies but they may not know or remember the Company Name but they do remember the person they speak to on a daily basis. Well, you don&#8217;t want to add a separate Combo Box for Company Name, First Name, [&#8230;]<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_785\" class=\"pvc_stats all  \" data-element-id=\"785\" 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":[64,44,18,31],"class_list":["post-785","post","type-post","status-publish","format-standard","hentry","category-access-tips","category-database-design","tag-access-tips","tag-combo-boxes","tag-database-design","tag-forms","odd"],"_links":{"self":[{"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/785","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=785"}],"version-history":[{"count":13,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/785\/revisions"}],"predecessor-version":[{"id":1281,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/785\/revisions\/1281"}],"wp:attachment":[{"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=785"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=785"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}