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
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