Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vbscript stopped working after fonversion to access 2002

Status
Not open for further replies.

cactus1000

Programmer
Aug 31, 2001
149
US
I had an event procedure that worked fine in Access 97, but doesn't work since converting to access 2002. When records are about to be printed, a message appears if no records are to be found, and a button appears which will take you back to the previous form ("selectrecs"). Does anyone know why this script no longer works?

Option Compare Database
Option Explicit

Private Sub Form_Open(Cancel As Integer)

Dim db As DAO.Database, rst As Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset(Me.RecordSource)

If rst.RecordCount = 0 Then
MsgBox "No records found to print." & Chr(13) & "Click OK to return to 'Select records for printing' menu", 64
DoCmd.OpenForm "selectrecs"
End
End If


End Sub
 
cactus1000

Ibelieve, by default, Access 2000 and 2002 do not support DAO.

You need to add DAO reference.

From your Acccess main menu, select the "View" menu item, select Debug Window. This will open up the Visual Basic window with your suppoting code.

From the VB window, select "Tools" menu item, and then select References.

Scroll down the list until you see someting like...
Microsoft DAO 3.6 Object Library

You can only choose one reference for DAO, and I suspect the enwest version is the best.

The DAO reference must be added for anyone using your database.

Richar
 
I already have DAO 3.6 checked, so it must be something else.

Thanks, though!
 
cactus1000

I assume the DAO referenced is checked. (Just checking ;-) )

What is Me.RecordSource

And have you tried using rst.MoveFirst before the record count operation?

Richard
 
It turns out that this script will open other forms, just not the one I want. The form in question opens fine through macros, etc. What could be wrong with it?
 
I just had a scary thought. Is "selectrecs" a reserved word in Access 2000/2002?
 
willir

Try recompiling the form. Better yet, run the Compact and Repair database utility from the tools menu.

Richard
 
I did the compact and repair, but no luck. If I change the name of the form (and change the script accordingly), everything works. Access doesn't like the name "selectrecs". I know "select" is a reserved word. Is this the problem?
 
Weird, and I suppose it is possible. (I can't test right now) Antoher thing that would make Access complain very loudly is if you have objects with the same name -- table and form object fro example. (Which begs the question why the form wizard uses the table name as the default form name)

I would mark it up to a conversion issue and move on. You got the import thing -- your code works.

Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top