Solved

automating importing excel data into access database-xtra blank records display

Posted on 2011-03-07
5
329 Views
Last Modified: 2012-05-11
Hello,
i have a excel worksheet on local network- the sheet has a number or fields - but the only field that is filled in when it is imported is the first field 'serial number'- the other fields are blank-
( do not know if this matters).
[procedure]:
User hits button on form in access database- to import data in-
data imports successfully-
When user exits database -they hit button which delete data from table-
User deletes serial numbers on excel sheet and enters new numbers
then procedure happens again:
this time: User hits button on form in access to import data in
and it imports successfully-
ONLY - when they view table to see data imported correctly-
there are extra blank fields
for example if only 4 serial numbers
maybe second time they import- there are 4 extra blank records in table
-do you know what can be causing this?
thank you

Private Sub Command16_Click()
DoCmd.TransferSpreadsheet , acSpreadsheetTypeExcel9, "Table2", "\\network1\tw\Excel\Cost1\Table1.xls", True, "Table1!"
DoCmd.OpenForm "frmImport"
Me.Form.Refresh

Exit_CmdImportExcel_Click:
Exit Sub
Err_Command0_Click:
MsgBox Err.Description
End Sub



Private Sub Command26_Click()
CurrentDb.Execute "qryDeleteTable2", dbFailOnError

DoCmd.Quit

Open in new window

0
Comment
Question by:davetough
5 Comments
 
LVL 18

Expert Comment

by:Richard Daneke
ID: 35057840
The import is importing the area defined in Excel as a Table  (Table2?)

When the delete removes the rows, the table is still defined in Excel
When new data is entered in Excel, your testing is not replacing all of the rows from the earlier table.

0
 
LVL 3

Expert Comment

by:JAMcDo
ID: 35057959
I concur with DoDahD in that the number of rows is set by previous data entry.

See if you can reset the row range before the subsequent import - either manually or with a macro.

J.
0
 

Author Comment

by:davetough
ID: 35058023
only part understand- first how can I manually reset row range?
thank  you
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 35058321
change this

DoCmd.TransferSpreadsheet , acSpreadsheetTypeExcel9, "Table2", "\\network1\tw\Excel\Cost1\Table1.xls", True, "Table1!"
DoCmd.OpenForm "frmImport"


with this

DoCmd.TransferSpreadsheet acimport, acSpreadsheetTypeExcel9, "Table2", "\\network1\tw\Excel\Cost1\Table1.xls", True, "Table1!"
DoCmd.OpenForm "frmImport"
0
 

Author Closing Comment

by:davetough
ID: 35058476
thanks
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now