473,382 Members | 1,349 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Show number of records exported to Excel in msgbox

547 512MB
Is it possible to show the number of records that were exported to Excel, using" transferspreadsheet" method, in the msgbox that i use to show the process is complete? Any ideas?
Aug 27 '13 #1
5 3153
jimatqsi
1,271 Expert 1GB
I would immediately link to the spreadsheet, open a recordset on the link and get the record count.
Expand|Select|Wrap|Line Numbers
  1. DoCmd.TransferText acLinkDelim, , SomeTblName, SomeExcelName, chkHasFieldNames
  2. dim rs as dao.recordset
  3. set rs = currentdb.openrecordset(SomeTblName,dbreadonly)
  4. rs.movelast
  5. msgbox "exported " & rs.recordcount & " records to Excel"
  6. rs.close
  7. set rs = nothing
  8.  
Jim
Aug 27 '13 #2
jimatqsi
1,271 Expert 1GB
Conversely, you could open whatever table or query you used to export and get your count there. But you would be assuming 100% success to the Excel file.

Jim
Aug 27 '13 #3
ADezii
8,834 Expert 8TB
It would be a simple matter of determining how many Records were in the Data Source, once the Transfer has been completed, as in:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdTest_Click()
  2. On Error GoTo Err_cmdTest_Click
  3. Dim strPATH As String
  4. Dim strDataSource As String
  5. Dim intRecsTransferred As Integer
  6.  
  7. strDataSource = "qryEmployeesByState"
  8. strPATH = "C:\Test\Employees By State.xls"
  9.  
  10. DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, strDataSource, _
  11.                           strPATH, True
  12.  
  13. 'If you get here, all went well, get the Count of Records Transferred
  14. intRecsTransferred = DCount("*", strDataSource)
  15.  
  16. 'Confirmation
  17. MsgBox intRecsTransferred & " Records have been Transferred to " & strPATH, _
  18.        vbInformation, "Transfer Complete"
  19.  
  20.  
  21. Exit_cmdTest_Click:
  22.   Exit Sub
  23.  
  24. Err_cmdTest_Click:
  25.   MsgBox Err.Description, vbExclamation, "Error in Excel Transfer"
  26.     Resume Exit_cmdTest_Click
  27. End Sub
Aug 27 '13 #4
jimatqsi
1,271 Expert 1GB
I like the DCount way better than my recordset manipulation. Might be best to do DCount on the exported result rather than the source query/table.

Jim
Aug 27 '13 #5
neelsfer
547 512MB
thx guys for the prompt responses. i will give it a try and let you know
Aug 27 '13 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: William Buchanan | last post by:
Hi folks I want to show 2 records on a page side by side. Each record has an image which will be displayed and a bit of text. How can I do this? Thanks Will
2
by: Zeljko | last post by:
I'm creating Address book. Header of the main form (frmAddress) contains combo box (cboFilter) to filter records by Occupation on main Form(Ocupation1). That's working. Combo box also have "Show...
2
by: jaishu | last post by:
Hi, I am getting this error "The command or action 'Show all records' isn't available now", i get this when i try to do DoCmd.ShowAllRecords DoCmd.GoToControl ("ID") DoCmd.FindRecord...
2
by: ontherun | last post by:
Hi, Could anyone please assist me on how to import Excel records to Access. the records in excel are not in the same order as that of the one in Access. there are about 1000 records needs to be...
1
by: veaux | last post by:
Might not have explained this correctly in subject, but query results look like below: Name ID Phone Bill 001 123 Bill 001 234 Bill 001 ...
1
by: ochalove26 | last post by:
hi all, i'm a new programmer... i use a combo box to filtering the records in my sub form..it was works...but when i want to show all records in my sub form it doesnt works..how it would be?please...
6
by: sranilp | last post by:
Hi Friends, My name is Anil,i will use the Business Objects/COGNOS which will retrives the morerecords like 3,00,000.I will create the .csv/.txt file for this and import to Access and do the pivot...
14
by: veer | last post by:
can any one help by providing the method inserting the records in excel file because i created it all it works fine but i have no idea about how to insert new records in the existing excel file....
0
by: trtaan | last post by:
Hi all, This is trtaan. I wanted to export around 300000 records that are present in my MS Access 2003 version table to excelsheet version8. I had written a code to export to multiple sheets in...
3
aryanraj
by: aryanraj | last post by:
Hi all, I wanted to export around 300000 records that are present in my MS Access 2003 version table to excelsheet version8. I had written a code to export to multiple sheets in one workbook,...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.