|
-
Jul 15th, 2001, 12:28 AM
#1
Thread Starter
New Member
Cant figure out how to do this
I am wanting to create a VB frontend for an access database that will record the Time of a login (Record Creation) the time of a logout(closing of record) and then have a field that tells me how much time was spent between the two. The Problem is that I cannot seem to figure out how to do this.
This is a login program for my schools Math Tutoring center. We are getting statistics of who is coming in and for how long. I am not making this that highly developed but would like to when I learn more. Right now I just want to figure out how to do this time thing.
the fields I have in a record are
Student First Name
Student Last Name
Student SSN (optional)
Time Entered
Time left
Total Time Stayed
then have a bunch of checkboxes for the classes they are getting help with
Please Help
Ben
-
Jul 15th, 2001, 04:49 AM
#2
Fanatic Member
First put a Timer control on a form.
Here some code:
Private Sub Timer1_timer()
Clock.text = Format(Time, "hh:mm:ss"
If txtBegTime.Text > Format("00:00:00", "hh:mm:ss") then
Calc_Time Clock, txtBegTime
txtResult.text = RetVal
End If
End Sub
Public Function Calc_Time(ByVal inTime As Date, endTime As Date)
Retval = Format(endTime - inTime, "hh:mm:ss")
End Function
Private Sub Form_Activate()
Timer1.Enabled = True
txtBegTime = Format("00:00:00", "hh:mm:ss")
txtEndTime = Format("00:00:00", "hh:mm:ss")
txtResult = Format("00:00:00", "hh:mm:ss")
End Sub
Because you're not living in Europe change the hh:mm:ss
in your format.
Maybe this helps you on the way.
cheers
Ray
-
Jul 15th, 2001, 01:15 PM
#3
Thread Starter
New Member
OK, but will this allow someone to login before the other person logs out?
We have one person come in and then another person will come in before that person leaves...
What I was tring to do is get the ammount of time from two different variables within the database the time entered and time left and then somehow subtract the two
-
Jul 16th, 2001, 02:24 AM
#4
Fanatic Member
The sample I give you is just a timer sample.
Now for your problem, because of different users,
your idea creating records on a database is good.
When a user logs in then you put the time in your
begintime field.
When the user logs out, you have to search for the
users record and put the time in the endTime field.
Now you can substract the two time fields and put the
result in the result field.
There'is no need to use a timer because you will use
the system time.
Do not forget to use the Format statement as shown in
my sample.
Cheers
Ray
-
Jul 17th, 2001, 10:33 PM
#5
Thread Starter
New Member
This is what I used in case anyone wants to see. I used 24 hour format to make time calculation better
Public Function Calc_Time(ByVal inTime As Date, ByVal endTime As Date)
lblTotTime.Caption = Format(endTime - inTime, "H:mm:ss")
End Function
Thank you For your help
Now on to more problems
I need to find a way to set up two passwords one for a Manager password and a Tutor Password
The manager needs to be able to change both passwords BUt again as I have just started all of this a few days ago I am lost...but getting there
-
Jul 18th, 2001, 03:50 AM
#6
Fanatic Member
try this...
get the time user entered, get the time user left, then use the
DateDiff function to compute how long he stayed.
see msdn help for teh syntax of datediff
On Error GoTo Hell
Hell:
Kill Me
Food For Thought:
- Do not judge a book... if you're not a judge!

Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|