Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Append Excel Spreadsheet to Access Database using ASP

Status
Not open for further replies.

mgagliardi

Technical User
Aug 12, 2005
3
US
I have an excel spreadsheet that I use to map data that I recieve from various sites. Once the spreadsheet does its magic, I then use an Access VB routine to update the access database using a few SQL statements to identify and delete the old data, then a docmd.transferspreadheet function to import the spreadsheet into a table in access that has the exact same field names as the spreadsheet. Then finally I run an append query to update the appropriate table with acces itself. My problem is, I have to export the Access database to my local computer, run the routine described above and then reimport the database back to my web hosts server. I want to be able to do this all from an asp page, or a suggested better route than downloading and uploading my entire database. Here is a copy of the Access VB routine I run incase it helps:

Private Sub UpdateAZHHA_Click()
On Error GoTo Err_UpdateAZHHA_Click

Dim delAZHHAtbl As String
Dim delAZ As String
Dim appendAZ As String

delAZHHAtbl = "DELETE AZHHA.* FROM AZHHA"
delAZ = "DELETE tblOrders.*, tblWorksites.ClientID FROM tblWorksites INNER JOIN tblOrders ON tblWorksites.WorksiteID = tblOrders.WorksiteID WHERE (((tblWorksites.ClientID)=5))"
appendAZ = "INSERT INTO tblOrders ( WorksiteID, StatusID, SpecialtyID, ShiftID, DisciplineID, BonusPaidBy, Notes, StartDate, EndDate, CertIMPFLD )SELECT AZHHA.WorksiteID, AZHHA.StatusID, AZHHA.SpecialtyID, AZHHA.ShiftID, AZHHA.DisciplineID, AZHHA.BonusPaidby, AZHHA.Notes, AZHHA.StartDate, AZHHA.EndDate, AZHHA.CertIMPFLD FROM AZHHA"
DoCmd.SetWarnings False
DoCmd.RunSQL delAZHHAtbl
DoCmd.RunSQL delAZ

DoCmd.TransferSpreadsheet acImport, , "AZHHA", _
"C:\COMS\AZHHAimport.xls", _
True, "Import!"

DoCmd.RunSQL appendAZ

Exit_UpdateAZHHA_Click:
Exit Sub

Err_UpdateAZHHA_Click:
MsgBox Err.Description
Resume Exit_UpdateAZHHA_Click

End Sub
 
something like this:

Code:
<%
 set access = server.createobject("Access.Application")
 access.opencurrentdatabase "c:\somedatabase.mdb"
 access.docmd.runmacro "mymacro"
 access.quit
%>


-DNG
 
Thank you for he reply, but I have a question. I went into my database and wrote a macro that calls up the spreadsheet processing function I mention above and tested it. It works off line. However in the Access Function the spreadsheet is located at c:\coms\azhhaimport.xls, but on line it is upload to ../fpdb/azhhaimport.xls.

Will I need to change the reference in the Access Function and how would it look? I have tried ../fpdb/azhhaimport.xls, but it does not work. I use a DSN-less connection to the database and server.mappath. Or is there something I can do to leave the spreadsheet on my local machine?

Thanks in advance
 
try using...something like this:

access.opencurrentdatabase Server.Mappath("/fpdb/azhhaimport.xls")

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top