Dynaset ???

J

Josh Grameson

In an application here I found this code bellow. When I try to compile it I
get an error on the ‘ds As Dynaset’. In another place in this database I get
same error on ‘Dim MyTable As Table’. This application was an Access 97
application and it was converted by Access to Access 2K.



Why is this failing, and can I fix this?









Function CheckDays()



iOptSetting% = DLookup("ShowDays", "Person", "[ID] =
Forms!Global!Logon")

If iOptSetting% Then

Dim db As Database, ds As Dynaset

Set db = CurrentDb()

Set ds = db.CreateDynaset("ComingImptDays")

If ds.EOF Then

iRetVal% = False

Else

iRetVal% = True

End If



ds.Close

db.Close

Else

iRetVal% = False

End If



CheckDays = iRetVal%



End Function
 
D

Dirk Goldgar

Josh Grameson said:
In an application here I found this code bellow. When I try to
compile it I get an error on the 'ds As Dynaset'. In another place in
this database I get same error on 'Dim MyTable As Table'. This
application was an Access 97 application and it was converted by
Access to Access 2K.

Why is this failing, and can I fix this?


Function CheckDays()

iOptSetting% = DLookup("ShowDays", "Person", "[ID] =
Forms!Global!Logon")

If iOptSetting% Then

Dim db As Database, ds As Dynaset

Set db = CurrentDb()

Set ds = db.CreateDynaset("ComingImptDays")

If ds.EOF Then

iRetVal% = False

Else

iRetVal% = True

End If



ds.Close

db.Close

Else

iRetVal% = False

End If



CheckDays = iRetVal%



End Function

The old, Access 97 version of the application was already using obsolete
code, which was probably supported by a library reference to a
compatibility library. I haven't done a conversion of such old code
myself, but my best suggestion is that you do the following to bring it
up to date (working on a copy, in case something goes wrong):

1. Open any code module, then click Tools -> References..., and make
sure a reference to the Microsoft DAO 3.6 Object Library is checked. At
the same time, remove the check mark, if any, next to the Microsoft
ActiveX Data Objects 2.x Libary.

2. Change all declarations of objects "As Dynaset" to "As Recordset".

3. Change all declarations of objects "As Table" to "As Recordset".

4. Change all calls to the "CreateDynaset" method to "OpenRecordset".

Save all your changes, compile the database project, and see if you get
any errors. If not, try it out and see if it works properly.
 

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

Similar Threads

Immediate Window? 2
Trying to write a select statement in VBA; Access 2002 1
listbox selection 2
Help with Optionbutton 2
Database Issue 9
Compile error faced 2
DAO ColunmWidth 4
print code error 5

Top