old A97 code?

A

Andrew Gould

I just recently converted a database from A97 to A2K2. I keep getting the
error, "User-defined type not defined". I've check the references and the
old database when opened in 97 lists:

-VBA
-MSAccess 8.0 Object Library
-Microsoft DAO 2.5/3.5 Compatibility Library
-utility
After importing all tables, forms, ect into an A2K2 new database I attempted
to match the references as close as possible to:

-VBA
-MSAccess 10.0 Object Library
-MS DAO 3.6 Object Library
I'm still getting that same error all over the place. I looked at the code
and it looked a little old but wasn't for sure. Here is the part of the
code that keeps giving me problems, can someone please tell me if the code
needs to be redone or is it something else.

On Error GoTo Err_Complete_Class
Dim db As Database
Dim History As Table
Dim Class As Snapshot
Dim CCount As Control
Dim TotEnroll As Control
Set TotEnroll = Me![*Complete Class].Form![Total Enrolled]
Set CCount = Forms![Complete Class]![Class Counter]
Set db = CurrentDb()
Set Class = db.CreateSnapshot("Class Schedule")
Set History = db.OpenTable("Class History")

If Me![Status] <> 0 Then
MsgBox "This Class Has Already Been Closed Or Canceled.", 0, "ADP
Continuing Education"
Else

Class.FindFirst "[Class Counter] = " & CCount

For I = 1 To TotEnroll
History.AddNew
History("Date") = Me![Date 1]
History("Student ID") = Class("Student ID")
History("Class ID") = Me![Class ID]
History("Instructor") = Me![Instructor]
History("Blue Tag") = Class("Blue Tag")
History.Update
Class.FindNext "[Class Counter] = " & CCount
Next
Me![Status] = 1
History.Close
DoCmd.Close A_FORM, "Complete Class"
End If
 
R

Roger Carlson

This database was previously converted from Access 2.0 to Access 97 as
evidenced by the Compatibility Library (Microsoft DAO 2.5/3.5 Compatibility
Library). This was a 'bridge' program that allowed the old "Access Basic"
code to work with VB. The differences were small but there are some.

It has been a while, but I believe that the "Table" data object is no longer
supported. That should be changed to a Recordset object and the OpenTable
method should be change to OpenRecordset
Dim History As DAO.Recordset
Set History = db.OpenRecordset("Class History", dbOpenTable)

also, change the Snapshot object to a recordset object
Dim Class As DAO.Recordset
Set Class= db.OpenRecordset("Class Schedule", dbOpenSnapshot)

Also (although I don't see a problem below) VB is pickier about use of the
dot (.) and bang (!). Several places that Access Basic allowed the dot, VB
required a bang. In addition, the DoCmd statement did not require a dot in
Access Basic but does in VB:

Access Basic: DoCmd Requery
VB: DoCmd.Requery

There may be others, but those are the most common. You'll have to fix all
the compile errors before you can continue.

--
--Roger Carlson
www.rogersaccesslibrary.com
Reply to: Roger dot Carlson at Spectrum-Health dot Org


Andrew Gould said:
I just recently converted a database from A97 to A2K2. I keep getting the
error, "User-defined type not defined". I've check the references and the
old database when opened in 97 lists:

-VBA
-MSAccess 8.0 Object Library
-Microsoft DAO 2.5/3.5 Compatibility Library
-utility
After importing all tables, forms, ect into an A2K2 new database I attempted
to match the references as close as possible to:

-VBA
-MSAccess 10.0 Object Library
-MS DAO 3.6 Object Library
I'm still getting that same error all over the place. I looked at the code
and it looked a little old but wasn't for sure. Here is the part of the
code that keeps giving me problems, can someone please tell me if the code
needs to be redone or is it something else.

On Error GoTo Err_Complete_Class
Dim db As Database
Dim History As Table
Dim Class As Snapshot
Dim CCount As Control
Dim TotEnroll As Control
Set TotEnroll = Me![*Complete Class].Form![Total Enrolled]
Set CCount = Forms![Complete Class]![Class Counter]
Set db = CurrentDb()
Set Class = db.CreateSnapshot("Class Schedule")
Set History = db.OpenTable("Class History")

If Me![Status] <> 0 Then
MsgBox "This Class Has Already Been Closed Or Canceled.", 0, "ADP
Continuing Education"
Else

Class.FindFirst "[Class Counter] = " & CCount

For I = 1 To TotEnroll
History.AddNew
History("Date") = Me![Date 1]
History("Student ID") = Class("Student ID")
History("Class ID") = Me![Class ID]
History("Instructor") = Me![Instructor]
History("Blue Tag") = Class("Blue Tag")
History.Update
Class.FindNext "[Class Counter] = " & CCount
Next
Me![Status] = 1
History.Close
DoCmd.Close A_FORM, "Complete Class"
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top