Import VBA from Excel Spreadsheet not working

mari_hitz

Registered User.
Local time
, 16:46
Joined
Nov 12, 2010
Messages
120
Hi everyone,

Hope you are good. Hope you can help me out on this. I've been trying to make a database and to import info from an excel spreadsheet to an access table. I have used a code I found on the web and the same does not returns errors, however, when I go to the table in acess that should contain the info only contains rows created in blank. On the spreadsheet I have only 200 rows, and on the access more than 6,000 rows are created. Do you have any idea why?

This my code:

Code:
Private Sub cmdImport_Click()
    'Unset warnings
    DoCmd.SetWarnings False
    
    'SQL delete statement
    DoCmd.RunSQL "DELETE * FROM tblPymElectionCurrent"
    
    'Import spreadsheet
    DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "tblPymElectionCurrent", selectFile(), True, Range:="Payment List$"
           
    DoCmd.SetWarnings True

End Sub

Thanks in advance!
 
usu blanks.
after the import ,run a query to delete blanks.
docmd.openquery "qdDelBlanksFromImport"
 
usu blanks.
after the import ,run a query to delete blanks.
docmd.openquery "qdDelBlanksFromImport"

Thanks Ranman256! Please note that the issues is not that it pastes my information on the spreadsheet in addition to rows in blanks, it does not paste the info instead creates 6,0000 in blank. Do you know why this might happen?

Thanks!
 
then try attaching the spreadsheet as a table.
if you can see the data as a table , then just run a query to transfer it.

if you cannot see data, it may be a version error in the excel.
 
..

Code:
..
    DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "tblPymElectionCurrent", [B][COLOR=Red]selectFile()[/COLOR][/B], True, Range:="Payment List$"
...
Thanks in advance!
What is selectFile()? I think the problem lays here.
 

Users who are viewing this thread

Back
Top Bottom