472,341 Members | 2,250 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,341 software developers and data experts.

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 5430
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
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--- ...
17
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...
2
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...
25
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...
12
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...
1
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...
21
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...
12
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...
12
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...
1
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...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...

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.