dim as database in 2000

gbanks

Registered User.
Local time
Today, 19:24
Joined
Feb 9, 2000
Messages
161
The problem I'm havin is you can't set the second line to Dim dbs As Database in 2000.. It's not an option.. I converted this to 2000 and it gave me an error message which says "Object variable not defined" I then looked at the selection and database is not an option.. I have this code run on the OnOpen event of a report.. It's used to set the record source.. Any thoughts on what I can replace database with? Thanks...

Private Sub Report_Open(Cancel As Integer)
Dim dbs As Database
Dim rstTmp, rstRep As Recordset
Dim tmpTo, tmpDesc As String
'Return reference to current database.
Set dbs = CurrentDb
Set rstRep = dbs.OpenRecordset("IDCReportTBL")
Set rstTmp = dbs.OpenRecordset("SELECT * FROM [IDC RECEIPT DELIVERY TBL] ORDER BY To,Descrip;")

' Populate Recordset object.
rstTmp.MoveLast
' Return to first record.
rstTmp.MoveFirst

' Do until end of file.
Do Until rstTmp.EOF
' Check and see if this record is for a different person and/or description than the last one
'if so just save it to the IDCReportTBL
If tmpTo <> rstTmp!To Or tmpDesc <> rstTmp!Descrip Then
rstRep.AddNew
rstRep("Receipt#") = rstTmp("Receipt#")
rstRep!To = rstTmp!To
tmpTo = rstTmp!To
rstRep("Room #") = rstTmp("Room #")
rstRep!Qnty = rstTmp!Qnty
rstRep!Descrip = rstTmp!Descrip
tmpDesc = rstTmp!Descrip

Else ' if it is the same than append the additional receipt#s and update the qty in the previous record
rstRep.Edit
rstRep("Receipt#") = rstRep("Receipt#") & " " & rstTmp("Receipt#")
rstRep!Qnty = rstRep!Qnty + rstTmp!Qnty
End If
rstRep.Update 'save the update
rstRep.MoveLast ' make sure current record in report table is the last one
rstTmp.MoveNext ' move to the next record in the temp table
Loop ' go back and do it again

' all done so close everything up and let the report run
rstRep.Close
rstTmp.Close
Set dbs = Nothing
End Sub
 
Hi
I think I had the same problem as you a short time ago. I was informed by 'accesswatch' and 'JMARZ'.
In the VBA window, select tools | References and check you have the Microsoft DAO 3.6 Object Library selected.

Hope this helps
Lorraine
 
You first need to check the references in the VBE window.
Tools, References: from there you will find the references that Access is using. To use DAO code (which is what previous versions used) you will have to add it manually by checking the box beside Microsoft DAO 3.6 Object Library, as this is not a default reference set by Access.

Then use
Set dbs as DAO.Database
and carry on as normal.
 
You first need to check the references in the VBE window.
Tools, References: from there you will find the references that Access is using. To use DAO code (which is what previous versions used) you will have to add it manually by checking the box beside Microsoft DAO 3.6 Object Library, as this is not a default reference set by Access.

Then use
Set dbs as DAO.Database
and carry on as normal.
 

Users who are viewing this thread

Back
Top Bottom