954,582 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Help with my system, comparing current time to the database time pls help

Good day to all, Im creating a computer laboratory admission system, and one of the functions of my program using a bar code reader, this how the system runs, assuming that mr. villa has the bar code and the code is 00123456789 then after you scanned it, it will look into a database which contains hundreds of info, maybe we have 400-500 students at our school, im one of them, after that the program will compare mr.villa's time comlab staying time and the current time
for example, mr. villa scanned at 2:14pm, and his staying time at comlab is 2:00-3:00pm, so it means he is 14minutes late, the program will unlock the door and mr.villa can now enter the computer laboratory,
how can i compare the current time to the time in and time out of the students in the database?
i need to consider also the days, some students have Monday, Wednesday, Friday classes, or Tuesday, Thursday classes and so on...

I have a code but that is only for the input of the code "ive only used textbox to input student number because im still looking for a bar code reader"

my database columns are

StudentName, TimeIn, TimeOut, StudentID "the student number it is unique but i didnt set it as primary key", 1day, 2day, 3day "1day symbolizes the first day of the week a student needs to go to school for example his 1day is monday, 2day is wednesday, 3day is friday, if a student has only 2 days of classes in the comlab im inputting the 3day as none"

ive attached a SS of the database and the current program at vb to give you an idea


Dim WithEvents pol As Timer

Private Sub cmdInput_Click()

Adodc1.RecordSource = "select * from Login where 1day like '" + txtInput.Text + "'"
Adodc1.Refresh

End Sub

Private Sub Form_Load()
Form1.BorderStyle = fixedsingle


Set pol = Form1.Controls.Add("vb.timer", "pol", Form1)
With pol: .Interval = 200: .Enabled = True: End With


Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\studentdatabase.mdb;Persist Security Info=False"
Adodc1.RecordSource = "Select * from Login"
Set DataGrid1.DataSource = Adodc1

End Sub
Private Sub Pol_Timer()
txtTime.Text = Format$(Time, "hh:mm:ss AM/PM")
txtDate.Text = Format$(Now, " mmmm dd, yyyy")
txtDay.Text = Format$(Now, "dddd")
End Sub

Attachments db.JPG 37.4KB 1.JPG 25.24KB
xtianenikkian
Light Poster
39 posts since Sep 2008
Reputation Points: 11
Solved Threads: 3
 

If understand this correctly, try the following-

Dim MyTime As Date, DataTime As Date

MyTime = Format(Now, "hh:mm:ss")
DataTime = 'Get the time from your database here

If MyTime > DataTime Then
   ' Code to Open Door
      Else
   Code To Close Door
End IF
AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
 

i think that helps but can you always visit me in this thread if i have another questions? thanks :))

xtianenikkian
Light Poster
39 posts since Sep 2008
Reputation Points: 11
Solved Threads: 3
 

It was a pleasure.:)

First things first, please mark this as solved. The solved button is at the bottom of this.

Secondly, if you have any more questions, please open a new post and I will be there. I will see this thread as closed and will not answer anything more on this, except for the original question.;)

AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
 
Dim MyTime As Date, DataTime As Date

MyTime = Format(Now, "hh:mm:ss")
DataTime = 'Get the time from your database here

If MyTime > DataTime Then
   ' Code to Open Door
      Else
   Code To Close Door
End IF


can you fill up the 'Get the time from your database here' ive taken SQL a long time ago and im having a hard time reviewing it, the info of my system is attached you can also see the fields

xtianenikkian
Light Poster
39 posts since Sep 2008
Reputation Points: 11
Solved Threads: 3
 

You will be using something like -

myRS.Open "SELECT MyDateField FROM MyTableName WHERE DateValue(" & "'" TextDate.Text & "')", con, adOpenStatic, adLockOptimistic

If myRS.EOF = True Or myRS.BOF = True Then
Exit sub
Else
DataTime = myRS!MyDateField


You can also do this without the "DateValue()" part.

AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You