Log in

View Full Version : Solved: Data Disappeared



Philcjr
05-26-2011, 08:28 AM
I am using Access 2007 and just imported data from Excel files.

The data is there in Access but I can not see it. It is not a font color issue or cell shading issue. Is there some setting I am overlooking?:banghead:

I have over 1 Million records

Here is the code I used:

Option Compare Database
Option Explicit
Sub GetFilesNow()

Dim strPathFile As String, strFile As String, strPath As String, strTable As String
Dim blnHasFieldNames As Boolean

'Define if the first row in EXCEL worksheet has field names
blnHasFieldNames = True

'Define the folder that contains the EXCEL files
strPath = "C:\"

'Name of the table into which the data is going to be imported to
strTable = "MasterTable"

'Define file path and file name
strFile = Dir(strPath & "*.xls")

'Loop through files until done
Do While Len(strFile) > 0

On Error Resume Next
strPathFile = strPath & strFile

DoCmd.TransferSpreadsheet _
TransferType:=acImport, _
SpreadsheetType:=acSpreadsheetTypeExcel9, _
TableName:=strTable, _
FileName:=strPathFile, _
HasFieldNames:=blnHasFieldNames

strFile = Dir()
On Error GoTo 0
Loop

End Sub

hansup
05-26-2011, 12:52 PM
If you execute this statement in the Immediate Window, what does it say about the count?

Debug.Print DCount("*", "MasterTable")

Philcjr
05-26-2011, 06:26 PM
After coming back, I noticed that when I did the Import it brought in blank rows of data... 105,000 rows to be exact. There was a total of 1, 208,653 rows of data. So, I deleted the blank rows and all is fine.

That was scary, I thought I did something wrong.

Thanks for your help/input HANS :friends: