473,508 Members | 2,308 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(InTable 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.Workspaces(0).Databases(0)
Set MyInTable = MyDB.OpenRecordset(InTable, DB_OPEN_DYNASET)
Set MyOutTable = MyDB.OpenRecordset(OutTable, DB_OPEN_DYNASET)
If MyOutTable.EOF Then
Else
MyOutTable.MoveFirst
End If
X = False

'Read first record.
MyInTable.MoveFirst
DoCmd.Hourglass True

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

MatchKey = "[symbol] = '" & MyInTable("symbol") & "' and "
MatchKey = MatchKey & "[Policy] = '" & MyInTable("Policy") & "'
and "
MatchKey = MatchKey & "[Mod] = '" & MyInTable("Mod") & "'"
If Not MyOutTable.EOF Then 'Makes sure that the OutTable has
records in it
MyOutTable.FindFirst MatchKey
If MyOutTable.NoMatch = False Then
MyOutTable.Edit
MyOutTable("ImportCounter") = MyOutTable("ImportCounter")
+ 1
MyOutTable.Update
X = True
End If

End If

If X = True Then 'Skip this record
X = False
Else 'Append this record
MyOutTable.AddNew
MyOutTable("AgntCde") = MyInTable("AgntCde")
MyOutTable("Sym") = MyInTable("Sym")
MyOutTable("PolNum") = MyInTable("PolNum")
MyOutTable("Mod") = MyInTable("Mod")
MyOutTable("DueDte") = MyInTable("DueDate")
MyOutTable("Amt") = MyInTable("Amt")
MyOutTable("UWCde") = MyInTable("UWCde")
MyOutTable("AcctTrx") = MyInTable("AcctTrx")
MyOutTable("PayCde") = MyInTable("PayCde")
MyOutTable("CloseDte") = MyInTable("CloseDte")
MyOutTable.Update
MyOutTable.MoveFirst
End If
MyInTable.MoveNext
Loop
DoCmd.Hourglass False

MyInTable.Close
MyOutTable.Close
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 5569
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.google.c om...
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(InTable 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.Workspaces(0).Databases(0)
Set MyInTable = MyDB.OpenRecordset(InTable, DB_OPEN_DYNASET)
Set MyOutTable = MyDB.OpenRecordset(OutTable, DB_OPEN_DYNASET)
If MyOutTable.EOF Then
Else
MyOutTable.MoveFirst
End If
X = False

'Read first record.
MyInTable.MoveFirst
DoCmd.Hourglass True

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

MatchKey = "[symbol] = '" & MyInTable("symbol") & "' and "
MatchKey = MatchKey & "[Policy] = '" & MyInTable("Policy") & "'
and "
MatchKey = MatchKey & "[Mod] = '" & MyInTable("Mod") & "'"
If Not MyOutTable.EOF Then 'Makes sure that the OutTable has
records in it
MyOutTable.FindFirst MatchKey
If MyOutTable.NoMatch = False Then
MyOutTable.Edit
MyOutTable("ImportCounter") = MyOutTable("ImportCounter")
+ 1
MyOutTable.Update
X = True
End If

End If

If X = True Then 'Skip this record
X = False
Else 'Append this record
MyOutTable.AddNew
MyOutTable("AgntCde") = MyInTable("AgntCde")
MyOutTable("Sym") = MyInTable("Sym")
MyOutTable("PolNum") = MyInTable("PolNum")
MyOutTable("Mod") = MyInTable("Mod")
MyOutTable("DueDte") = MyInTable("DueDate")
MyOutTable("Amt") = MyInTable("Amt")
MyOutTable("UWCde") = MyInTable("UWCde")
MyOutTable("AcctTrx") = MyInTable("AcctTrx")
MyOutTable("PayCde") = MyInTable("PayCde")
MyOutTable("CloseDte") = MyInTable("CloseDte")
MyOutTable.Update
MyOutTable.MoveFirst
End If
MyInTable.MoveNext
Loop
DoCmd.Hourglass False

MyInTable.Close
MyOutTable.Close
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
8853
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...
17
27219
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...
2
4329
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...
25
3696
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...
12
5503
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...
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...
21
2515
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...
12
3197
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...
12
1623
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...
1
4804
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...
0
7324
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,...
1
7042
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...
0
5627
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5052
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...
0
4707
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...
0
3193
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3181
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1556
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 ...
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.