473,545 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Automation Error

JC
I am getting a "Compile Error: Automation Error" with this function
and I can't figure out why. Can anyone help? The error hits as soon
as the function is recognized.

Function FileAppend(InTa ble As String, OutTable As String)
On Error GoTo Err_FileAppend

Dim MyDB As Database
Dim MyInTable As Recordset
Dim MyOutTable As Recordset
Dim MatchKey As String
Dim MatchOut As String
Dim X As Boolean
'Open table.
Set MyDB = DBEngine.Worksp aces(0).Databas es(0)
Set MyInTable = MyDB.OpenRecord set(InTable, DB_OPEN_DYNASET )
Set MyOutTable = MyDB.OpenRecord set(OutTable, DB_OPEN_DYNASET )
If MyOutTable.EOF Then
Else
MyOutTable.Move First
End If
X = False

'Read first record.
MyInTable.MoveF irst
DoCmd.Hourglass True

'Check to see if record exists in outtable
Do Until MyInTable.EOF

MatchKey = "[symbol] = '" & MyInTable("symb ol") & "' and "
MatchKey = MatchKey & "[Policy] = '" & MyInTable("Poli cy") & "'
and "
MatchKey = MatchKey & "[Mod] = '" & MyInTable("Mod" ) & "'"
If Not MyOutTable.EOF Then 'Makes sure that the OutTable has
records in it
MyOutTable.Find First MatchKey
If MyOutTable.NoMa tch = False Then
MyOutTable.Edit
MyOutTable("Imp ortCounter") = MyOutTable("Imp ortCounter")
+ 1
MyOutTable.Upda te
X = True
End If

End If

If X = True Then 'Skip this record
X = False
Else 'Append this record
MyOutTable.AddN ew
MyOutTable("Agn tCde") = MyInTable("Agnt Cde")
MyOutTable("Sym ") = MyInTable("Sym" )
MyOutTable("Pol Num") = MyInTable("PolN um")
MyOutTable("Mod ") = MyInTable("Mod" )
MyOutTable("Due Dte") = MyInTable("DueD ate")
MyOutTable("Amt ") = MyInTable("Amt" )
MyOutTable("UWC de") = MyInTable("UWCd e")
MyOutTable("Acc tTrx") = MyInTable("Acct Trx")
MyOutTable("Pay Cde") = MyInTable("PayC de")
MyOutTable("Clo seDte") = MyInTable("Clos eDte")
MyOutTable.Upda te
MyOutTable.Move First
End If
MyInTable.MoveN ext
Loop
DoCmd.Hourglass False

MyInTable.Close
MyOutTable.Clos e
Set MyInTable = Nothing
Set MyOutTable = Nothing

Exit_FileAppend :
Exit Function
Err_FileAppend:
MsgBox err.Number & " - " & err.Description , , "Function -
FileAppend"
Resume Exit_FileAppend

End Function
Nov 12 '05 #1
1 5576
Do you have a reference to DAO?

If you don't create one if you do try declaring the variables at the top as

Dim MyDB As DAO.Database
Dim MyInTable As DAO.Recordset
Dim MyOutTable As DAO.Recordset
Terry
"JC" <cl****@excite. com> wrote in message
news:36******** *************** ***@posting.goo gle.com...
I am getting a "Compile Error: Automation Error" with this function
and I can't figure out why. Can anyone help? The error hits as soon
as the function is recognized.

Function FileAppend(InTa ble As String, OutTable As String)
On Error GoTo Err_FileAppend

Dim MyDB As Database
Dim MyInTable As Recordset
Dim MyOutTable As Recordset
Dim MatchKey As String
Dim MatchOut As String
Dim X As Boolean
'Open table.
Set MyDB = DBEngine.Worksp aces(0).Databas es(0)
Set MyInTable = MyDB.OpenRecord set(InTable, DB_OPEN_DYNASET )
Set MyOutTable = MyDB.OpenRecord set(OutTable, DB_OPEN_DYNASET )
If MyOutTable.EOF Then
Else
MyOutTable.Move First
End If
X = False

'Read first record.
MyInTable.MoveF irst
DoCmd.Hourglass True

'Check to see if record exists in outtable
Do Until MyInTable.EOF

MatchKey = "[symbol] = '" & MyInTable("symb ol") & "' and "
MatchKey = MatchKey & "[Policy] = '" & MyInTable("Poli cy") & "'
and "
MatchKey = MatchKey & "[Mod] = '" & MyInTable("Mod" ) & "'"
If Not MyOutTable.EOF Then 'Makes sure that the OutTable has
records in it
MyOutTable.Find First MatchKey
If MyOutTable.NoMa tch = False Then
MyOutTable.Edit
MyOutTable("Imp ortCounter") = MyOutTable("Imp ortCounter")
+ 1
MyOutTable.Upda te
X = True
End If

End If

If X = True Then 'Skip this record
X = False
Else 'Append this record
MyOutTable.AddN ew
MyOutTable("Agn tCde") = MyInTable("Agnt Cde")
MyOutTable("Sym ") = MyInTable("Sym" )
MyOutTable("Pol Num") = MyInTable("PolN um")
MyOutTable("Mod ") = MyInTable("Mod" )
MyOutTable("Due Dte") = MyInTable("DueD ate")
MyOutTable("Amt ") = MyInTable("Amt" )
MyOutTable("UWC de") = MyInTable("UWCd e")
MyOutTable("Acc tTrx") = MyInTable("Acct Trx")
MyOutTable("Pay Cde") = MyInTable("PayC de")
MyOutTable("Clo seDte") = MyInTable("Clos eDte")
MyOutTable.Upda te
MyOutTable.Move First
End If
MyInTable.MoveN ext
Loop
DoCmd.Hourglass False

MyInTable.Close
MyOutTable.Clos e
Set MyInTable = Nothing
Set MyOutTable = Nothing

Exit_FileAppend :
Exit Function
Err_FileAppend:
MsgBox err.Number & " - " & err.Description , , "Function -
FileAppend"
Resume Exit_FileAppend

End Function

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
8858
by: Robert | last post by:
---EN--- This message has been crossposted in a french speaking newsgroup, english version is at the end. Thanks a lot for your help... --/EN--- Bonjour, Je développe une application intranet qui "tourne" maintenant depuis plusieurs années auprès de 2500 personnes environ, mais depuis 1 mois,
17
27238
by: Ange T | last post by:
Hi there, I'm having pain with the VB behind an Access form. The form is used to create reports in Excel based on the details entered in the form. This has always worked without error on my machine (NT4, Access 2k), however as soon as I attempt to create anything on another machine (NT4, Access 2k) which most users will be working from, I...
2
4330
by: Andante.in.Blue | last post by:
Our Access 97 database is a single-file (non-splitted, pure Access) hosted no a network server, accessed regularly by a handful of users around the office. Until recently (until the Great Blackout, actually), there have been no problem with the database. It seems to handle simultaneous users fine and did not cause any grief. The blackout...
25
3699
by: Neil Ginsberg | last post by:
I have a strange situation with my Access 2000 database. I have code in the database which has worked fine for years, and now all of a sudden doesn't work fine on one or two of my client's machines. The code opens MS Word through Automation and then opens a particular Word doc. It's still working fine on most machines; but on one or two of...
12
5508
by: Cheval | last post by:
Has anyone had any problems with inter-office automation between MS Word and MS Access in Office 2003? I have recently installed office 2003 in a new folder and have left the older office 2000 and office XP components installed. ie I have word/access/excel 2k/xp/2003 installed. I tried to do a usual access 2k to word 2k automation yet I get...
1
808
by: Jimmer | last post by:
I've got what should be an easy automation problem, but the solution simply isn't coming to me. I've got several public variables set up for automation as follows: Public gappExcel As Excel.Application 'ADO Object for Excel Automation Public gstrExcelDir As String 'Source or Destination Directory
21
2528
by: Neil | last post by:
Is there a way to trap an error generated in another app that is controlled via automation? I have an Access 2000 app that opens Word 2000 and proceeds to open a series of documents and, in each document, parse the contents and write it to an Access table (the Access app, after opening Word, runs a macro within Word which parses and writes to...
12
3203
by: elziko | last post by:
I'm using late binding (I must) to automate Excel. My code opens Excel after createing and poulating some sheets. My problem is that when the user finally decides to close Excel its process is left running until my application closes. I have tried setting my Excel.Application object to Nothing. I have tried to then fore the GC into...
12
1629
by: Tomas | last post by:
Hi, I have worked with VB.NET for half a year (semi-newbie). Currently I am looking around for some books for those that crossed the starting hurdle. There are too many books out there-make choosing, a bit of a gamble. If you have experience of good VB.NET books on general and office automattion, you could recommend, it would be greatly...
1
4809
by: Bruce | last post by:
Hello, I know this must be something simple I'm overlooking but I can't get err.raise inside a class to return anything but 440 - automation error. For example, if I create the following test class: Option Compare Database Option Explicit Private Sub Class_Initialize()
0
7401
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7423
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7757
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5329
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4945
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3443
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1884
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1014
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.