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