{"id":103,"date":"2012-10-14T09:19:20","date_gmt":"2012-10-14T09:19:20","guid":{"rendered":"http:\/\/regina-whipp.com\/blog\/?p=103"},"modified":"2021-03-21T23:32:22","modified_gmt":"2021-03-22T03:32:22","slug":"confirm-record-count-on-excel-import","status":"publish","type":"post","link":"https:\/\/regina-whipp.com\/blog\/?p=103","title":{"rendered":"Confirm record count after Excel import&#8230;"},"content":{"rendered":"<p>When importing records from Excel\u00a0here&#8217;s a way you can let the User know they all made it.<\/p>\n<p><strong>Step 1<\/strong>&#8230;<br \/>\nIn your Import code \u00a0include the UpdateUser() line&#8230;<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nFunction ImportMySpreadsheet()\r\n\r\n    Dim lngColumn As Long\r\n    Dim xlx As Object\r\n    Dim xlw As Object, xls As Object, xlc As Object\r\n    Dim dbs As DAO.Database\r\n    Dim rst As DAO.Recordset\r\n    Set xlx = CreateObject(&quot;Excel.Application&quot;)\r\n    Set xlw = xlx.Workbooks.Open(Me.txtImportPath &amp; Me.txtDirectoryName &amp; &quot;\\&quot; &amp; Me.txtFileName)\r\n    Set xls = xlw.Worksheets(1)\r\n    Set xlc = xls.Range(&quot;A2&quot;)\r\n    Set dbs = CurrentDb()\r\n    Set rst = dbs.OpenRecordset(&quot;tblImport&quot;, dbOpenDynaset, dbSeeChanges)\r\n\r\n   'UpdateUser found on http:\/\/regina-whipp.com\/blog\/?p=100\r\n    UpdateUser (&quot;Importing &quot; &amp; xls.usedrange.rows.Count \u2013 1 &amp; &quot; rows from spreadsheet\u2026&quot;)\r\n\r\n'balance of your code...\r\nEnd Function\r\n<\/pre>\n<p><span style=\"color: #000000;\"><strong>Step 2<\/strong>&#8230;<br \/>\n<\/span><span style=\"color: #000000;\">Then\u00a0go to\u00a0the <strong>On_Click<\/strong> event of the button you&#8217;re using for your Import\u00a0and after the line that calls\u00a0your Import code\u00a0place the line bolded below.<\/span><\/p>\n<p><span style=\"color: #888888;\">Private Sub cmdImport_Click()<\/span><\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n      Call ImportMySpreadsheet\r\n      Me.lblUpdate2.Caption = DCount(\u201ciImportID\u201d, \u201ctblImport\u201d) &amp; \u201d Records successfully imported!\u201d\r\n\r\n      balance of your code\u2026\r\n<\/pre>\n<p><span style=\"color: #888888;\">End Sub<\/span><\/p>\n<p><span style=\"color: #000000;\"><strong>Step 3<\/strong>&#8230;<br \/>\nGo back to your form and while still in Design View place\u00a0two Labels on your form, name one lblUpdate and the other name\u00a0lblUpdate2 and leave the Captions blank.\u00a0 (<strong>Tip <\/strong>~\u00a0If the Caption Property does not let you leave it blank, as in the Label disappears, add a period and Save.\u00a0 After the initial Save, remove the period and Save again.)\u00a0 lblUpdate will show you how many rows are in the Excel Spreadsheet and lblUpdate2 will tell you how many records made it into your Temp table, see Figure 1.\u00a0 If the counts don&#8217;t match they can then open the spreadsheet to see what went wrong.<\/span><\/p>\n<div id=\"attachment_338\" style=\"width: 282px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-338\" class=\"wp-image-338 size-full\" title=\"Import\" src=\"http:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2012\/10\/Import.png\" width=\"272\" height=\"93\" srcset=\"https:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2012\/10\/Import.png 272w, https:\/\/regina-whipp.com\/blog\/wp-content\/uploads\/2012\/10\/Import-150x51.png 150w\" sizes=\"auto, (max-width: 272px) 100vw, 272px\" \/><p id=\"caption-attachment-338\" class=\"wp-caption-text\">Figure 1<\/p><\/div>\n<p><span style=\"color: #000000;\">This is also useful when the\u00a0processing of data is going to take a few minutes.\u00a0\u00a0You can\u00a0let your Users know what&#8217;s going on so they don&#8217;t get over anxious with the mouse while waiting for the process to finish.<\/span><\/p>\n<p><strong>\u00a0Appendix<\/strong>&#8230;<\/p>\n<p style=\"text-align: left;\"><span style=\"color: #000000;\">Private Sub <a name=\"UpdateUser\"><\/a><strong>UpdateUser<\/strong>(strMsg As String)<br \/>\nlblUpdate.Caption = strMsg<br \/>\nMe.Repaint<br \/>\nDoEvents<br \/>\nEnd Sub<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"color: #000000;\"><a href=\"http:\/\/btabdevelopment.com\/\" target=\"_blank\" rel=\"noopener\">BTAB Development &#8211; Import and Export Excel via Access<\/a><\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"color: #000000;\"><a href=\"http:\/\/www.accessmvp.com\/KDSnell\/EXCEL_MainPage.htm\" target=\"_blank\" rel=\"noopener\">Ken&#8217;s Import and Export via Access<\/a><\/span><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_103\" class=\"pvc_stats all  \" data-element-id=\"103\" 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 importing records from Excel here&#8217;s a way you can let the User know they all made it.<\/p>\n<p>Step 1&#8230; In your Import code include the UpdateUser() line&#8230;<\/p>\n<p> Function ImportMySpreadsheet() Dim lngColumn As Long Dim xlx As Object Dim xlw As Object, xls As Object, xlc As Object Dim dbs As DAO.Database Dim rst As [&#8230;]<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_103\" class=\"pvc_stats all  \" data-element-id=\"103\" 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,1],"tags":[64,34,23,21],"class_list":["post-103","post","type-post","status-publish","format-standard","hentry","category-access-tips","category-general","tag-access-tips","tag-excel","tag-import-excel","tag-vba","odd"],"_links":{"self":[{"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/103","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=103"}],"version-history":[{"count":32,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/103\/revisions"}],"predecessor-version":[{"id":1419,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/103\/revisions\/1419"}],"wp:attachment":[{"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/regina-whipp.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}