coding for timesheet



I found this snipet on the internet:

Option Explicit

Function GetTimeCardTotal()
Dim db As database, rs As Recordset
Dim totalhours As Long, totalminutes As Long
Dim days As Long, hours As Long, minutes As Long
Dim interval As Variant, j As Integer

Set db = DBEngine.Workspaces(0).Databases(0)
Set rs = db.openrecordset("timecard")
interval = #12:00:00 AM#
While Not rs.EOF
interval = interval + rs![Daily Hours]
totalhours = Int(CSng(interval * 24))
totalminutes = Int(CSng(interval * 1440))
hours = totalhours Mod 24
mintues = totalminutes Mod 60

GetTimeCardTotal = totalhours & " hours and " & minutes & " minutes"

End Function

I am told to go to the immediate window and enter ? gettimecardtotal() which
will call the function. I am designing on a access 2000 system and when I
try to either run the program OR compile it, I get the same reaction telling
me that the "db as database" portion of this function is "user defined
type is not defined". I realize that database isn't a defined type, but can
someone tell me what I need to do to get past this or alternative coding.
This will read 4 records in a table and give me a total.

Intelligent replies welcomed, foolish ones will be in vain.


PC Datasheet

Open a code module and go to Tools - References. Uncheck MS ADO and check MS DAO

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question