In your DateDiff statement you're calculating the difference between
Date1 and Date2, but your variables are named TimeIn and TimeOut.

Make sure you have Option Explicit set so that you cannot use
undeclared variables.

Also, in your code TotalTime is an integer variable, not a form field.
 Is there also a field on your form called TotalTime?  I don't see
anywhere that you'd be putting a value into a field on your form.

You need one more statement.  Assuming that you have a text box on
your form called txtTotalTime, set its value to the value of your
calculated TotalTime variable.  

Me.txtTotalTime = TotalTime.

--- In [email protected], P S <[EMAIL PROTECTED]> wrote:
>
> Hello all. I am trying to code a database that calculates the time
difference of TIMEIN and TIMEOUT. 
> 
> I am attaching a small database. There are 4 fields: ID#, TIMEIN,
TIMEOUT, TOTALTIME. On the Form, there are 3 buttoms: Create TIMEIN,
Create TIMEOUT, and Calculate TOTALTIME.
> 
> My VB code is as follows:
> Private Sub Command8_Click()
>     timein = Time()
> End Sub
> 
> Private Sub Command9_Click()
>     timeout = Time()
> End Sub
> 
> Private Sub Command10_Click()
>     Dim totaltime As Integer
>     totaltime = DateDiff("s", date1, date2)
> End Sub
> 
> I'm trying to calculate time difference in seconds and minutes but I
can't get anything to appear in the TOTALTIME box. In the Table,
Timein and Timeout are in DATE format. Totaltime is in NUMBER format.
Any suggestions? 
> 
> Thanks,
> Pablo
> 
> 
>       
> 
> [Non-text portions of this message have been removed]
>


Reply via email to