access97 to access2000 problem

loki

Registered User.
Local time
Today, 07:45
Joined
May 4, 2001
Messages
58
Here is the situation. I used Access97 to create this but I have had to recreate it on Access2000, and can not get it to work. A user opens a ticket once a day and that date is captured in a date field and used as the primary key. They enter numbers in text boxes and that is all totaled up in a Total textbox. When a user opens the ticket the next day and starts to enter numbers, yesterdays total appears in a textbox called "Previous Total". This code accomplishes this in Access97 but in Access2000, it crashes because it doesn't recognize the "Dim db as database". Can anyone help?

Private Sub Form_BeforeInsert(Cancel As Integer)
Dim db As Database
Dim rec As Recordset
Dim strsql As String

Set db = CurrentDb()
strsql = "SELECT * FROM maintable WHERE date = (Date()-1)"

Set rec = db.OpenRecordset((strsql), dbOpenDynaset)

With rec
If Not .EOF And Not .BOF Then
previous_total = rec!total
End If
End With


rec.Close
Set rec = Nothing
End Sub
 
I actually tried doing "DIM db as DAO.Databse" and it didn't wotk. It didn't even give me any intelsense
 
No, I get DAO coming up in the intelsense but nothing when I put a ".database" after it. Should I not be puting the ".database" after the "Dim db as DAO.Database"
 

Users who are viewing this thread

Back
Top Bottom