DataBase - Transferspreadsheet error trapping

Asked By goaljohnbill
12-Nov-09 08:34 PM
Sorry if this is somwhere else in here but a day of searching in every
combination of keyword I could think of got me nothing.

I am using excel 2003 and access 2003 with some 2000 file format DBs

In access I would like to trap errors on import of excel worksheets so
that I can automatically run code to allow users to fix the excel
file. When I run test code of an import with error handling I still
get the default msg and the coded error handling is skipped.

I found the posts that say for error handling in action queries
replace
docmd.openquery "queryname"
with
db.execute "queryname"

to skip the access error msg and be able to use your own code. Is
there a comparable workaround for docmd.transferspreadsheet?


thanks in advance
Microsoft Excel
(1)
Excel
(1)
VBA
(1)
DbFailOnError
(1)
AppActivate
(1)
ImportTest
(1)
GoTo
(1)
Transferspreadsheet
(1)
  Tom van Stiphout replied to goaljohnbill
13-Nov-09 12:31 AM
THe proper syntax is:
db.execute "queryname", dbFailOnError

Have you tried attached Excel files? That in combination with an
Append query is an alternative to Docmd.Transferspreadsheet. But the
latter will throw a runtime error as well when needed.

What kinds of errors are you looking for?

Show us some code, stripped to the bare essentials.

-Tom.
Microsoft Access MVP
  goaljohnbill replied to Tom van Stiphout
13-Nov-09 06:58 PM
This code is at least the idea of what I think I would like to do. The
goal is to not have the default msg box (or the users choices it
includes) when the import file isnt correct and start the users on the
path to fixing the file automatically.



Function ImportTest()
On Error GoTo ImportTest_Err

DoCmd.TransferSpreadsheet acImport, 8, "Table1", "MyPath
\MyFile.xls", True, ""


ImportTest_Exit:
Exit Function

ImportTest_Err:
If Err.Number = 3022 Then
MsgBox "Dup V value fix in excel by running Macro8"
' I know there is automation I can use here but I would
like to get the error handling running first
AppActivate "Microsoft Excel"
Else
MsgBox "Unknown error contact Tech"
End If
Resume ImportTest_Exit

End Function

When I step through this code I get the the default msg box and answer
no (because i dont want incomplete data put in) that sends me to the
else of the IF.

The databases I would apply this to are 6-8 years old and have alot of
macro type automation that I am working on changing over to VBA to get
these types of functionality as I learn more programming

When you say attached you are refering to linking correct? That might
be a better answer anyway.

thanks
john
help
Microsoft-Newsgroups sollen ab Juni abgeschaltet werden DataBase Hallo, dieses ist absichtlich ein cross-posting, denn es betrifft (unter anderem) diese NGs. http: / / www.heise.de / newsticker / meldung / Microsoft-Newsgroups-werden-abgeschaltet-993861.html Ich w?rde es sehr bedauern, zuk?nftig auf die usenet umzuziehen? F?r Access gibt es de.comp.datenbanken.ms-access f?r Word + Excel g?be es de.comp.office-pakete.ms-office ganz logisch ist es nicht, aber Access Discussions SQL Server 2008 (1) SQL Server (1) Windows XP (1) Office XP (1) Microsoft Excel (1) Microsoft Word (1) Office 2003 (1) Silverlight (1) Hallo Imtraud, ich habe jetzt den Beitrag nicht nicht vorliegen. Das wird aber nocht rechtzeitig i Forum mitgeteilt. Gru?? Hajo MVP f??r Microsoft Excel Betriebssystem Vista Ultimate SP2 und Excel Version2007 SP2 http: / / Hajo-Excel.de / Irmgard Schwenteck schrieb
Writting ACCESS table to Excel DataBase I am trying to write to Excel and have this code. . which fails at line Dim Rst1 As New ADODB.Recordset, saying Resultsreportingworksheet.xls" '* **Opening Report Template Dim myDB As Database Set myDB = CurrentDb Set ExcelWindow = CreateObject("excel.application") ExcelWindow.Visible = True ExcelWindow.Workbooks.Open (DXrptPath) Dim DXrpt As Workbook Set DXrpt = ActiveWorkbook 1 Access Forms Coding Discussions ADODB.Connection (1) DXrpt.Application.WindowState (1) ADODB.Recordset (1) Microsoft Excel (1) ObjRNG1.CopyFromRecordset (1) ObjRNG.CopyFromRecordset (1) Excel (1) ObjRNG1.NumberFormat (1) hi, This indicates that you have not a reference to the Microsoft ADO library. Take a look at the ExportToExcel function: http: / / bytes.com / topic / access / answers a new module): Option Compare Database Option Explicit ' This module requires the following references: ' ' 1. Microsoft DAO Object Library ' 2. Microsoft Excel Object Library ' ' (To create the references, in the VBA
Format Excel Sheet after DoCmd.TransferSpreadsheet DataBase I have read through several of the topics on this runs ok and other times I get odd errors. . . = = = = = = = = = = = 'Run the selected query out to excel. . . DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, RunQry, fn, True 'Format the spreadsheet Dim xlApp As Object Dim As Object Dim FlNm As String 'Just the name of the file. Set xlApp = CreateObject("Excel.Application") xlApp.Visible = False Set xlWkb = xlApp.Workbooks.Open(fn) ' "fn" is the name with Set xlWkb = Nothing xlApp.Quit Set xlApp = Nothing = = = = = = = = = = I was also having trouble getting the excel application to close all the way. You can see it if you look in the ActiveWindow.FreezePanes (1) DoCmd.TransferSpreadsheet (1) ActiveWindow.FreezePanes (1) ActiveCell.SpecialCells (1) DoCmd.OpenQuery (1) Excel (1) You do not say what the random errors are, so it is a bit in the code they might be generated. However, I see that you are using the EXCEL intrinsic constant xlLastCell, which has NO meaning in your ACCESS VBA code because you are using late binding for EXCEL. The actual value of xlLastCell is 11, so replace the xlLastCell with the number 11
Kallal (1) MySQL (1) Windows Server 2003 (1) Visual Studio (1) SharePoint (1) NHibernate (1) Microsoft SQL Server (1) Hi, Besides that your code is full of SQL injection bugs because know about Jet and Ace will not see and correct your erroneous claims. Larry Linson Microsoft Office Access MVP Co-Author, "Microsoft Access Small Business Solutions", Wiley, 2010 Utter rubbish and utter nonsense. If a index is Kallal, Access' default JET engine, like it or not, was abandoned by its very maker Microsoft, first in favor of MSDE and later for SQL Server Express. There was no new the pearls of your wisdom and explain why companies like Oracle (guess what product) or Microsoft (SQL Server) prefer to license these for plenty-a-thousands of bucks while JET is like to humbly hint your highness to the collection of references on that site to Microsoft's knowledge base articles that make clear why JET is crap, i.e. MDB databases when its done in a civilized manner. Actually, I was responding to a question in microsoft.public.dotnet.languages.csharp unaware of the crosspost to your obvious home base. If I simple and local to one machine sharing client and server - an environment where JET should excel; transfer a database stored UML model of roughly 170MB from a JET mdb file to
Windows 7 Professional workstation? When doing the installation of Dynamics GP everything installs except the Microsoft SQL Server Native Client 9.0 I have attempted to download the client from here as well http: / / www.microsoft.com / downloads / details.aspx?familyid = df0ba5aa-b4bd-4705-aa0a-b477ba72a9cb&displaylang = en For what ever 4.00GB 2.96 GB usable Hi Kevin, There is a similar tread on the microsoft.public.forecaster newsgroup. . . you may want give a check. The link you provided below is latest SQL 2005 Feature pack is released currently at V9 on December 2008 : http: / / www.microsoft.com / downloads / details.aspx?FamilyID = 536FD7D5-013F-49BC-9FC7-77DEDE4BB075&displaylang = en Try to find GP. Install SQL Server first and then install Dynamics GP. David Musgrave [MSFT] Escalation Engineer - Microsoft Dynamics GP Microsoft Dynamics Support - Asia Pacific Microsoft Dynamics (formerly Microsoft Business Solutions) http: / / www.microsoft.com / Dynamics mailto:David dot Musgrave at microsoft dot com