Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 136,226 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,328 people online right now. Registration is fast and FREE... Join Now!




Time code

 
Reply to this topicStart new topic

Time code

asanda
13 Oct, 2008 - 02:33 AM
Post #1

New D.I.C Head
*

Joined: 6 Oct, 2008
Posts: 5

I am creating a time access control monitoring system that will record the time in for the employees as well as the the time out from work. the employees must login to the system when they come in. I Have a database with the field for time in. I want the VB to enter timein on the field when the user login. I've created the login form and it working fine. I have two table on my database one for login username and password and the otherone for workshift, they are linked together via a username. the time in fild is in the workshift table. but dont know how to enter the time on the timeIn field of the database. plz help


Thanx in advance

This is my login code
vb

Private Sub cmdOK_Click()
'check for any record, if there is no record there could be error when looping
If Data1.Recordset.RecordCount = 0 Then
MsgBox ("No recordset")
Exit Sub
End If
'check for correct username and password
Data1.Recordset.MoveFirst
Do While Not Data1.Recordset.EOF
If txtUserName = Data1.Recordset.Fields("Username") Then
If txtPassword = Data1.Recordset.Fields("Password") Then
LoginSucceeded = True
frmMain.Show
Me.Hide

End If

End If
Data1.Recordset.MoveNext
Loop
If Not LoginSucceeded Then
MsgBox "Invalid UserName/Password, try again!", , "Login"
txtPassword.SetFocus
SendKeys "{Home}+{End}"

Else
Unload Me
End If

End Sub

User is offlineProfile CardPM
+Quote Post

thava
RE: Time Code
13 Oct, 2008 - 03:29 AM
Post #2

D.I.C Regular
Group Icon

Joined: 17 Apr, 2007
Posts: 442



Thanked: 18 times
Dream Kudos: 50
My Contributions
try this
vb

dim Db as database
Private Sub cmdOK_Click()
set db = opendatabase("<your database path here>")
'check for any record, if there is no record there could be error when looping
If Data1.Recordset.RecordCount = 0 Then
MsgBox ("No recordset")
Exit Sub
End If
'check for correct username and password
Data1.Recordset.MoveFirst
Do While Not Data1.Recordset.EOF
If txtUserName = Data1.Recordset.Fields("Username") Then
If txtPassword = Data1.Recordset.Fields("Password") Then
LoginSucceeded = True
set rs = db.openrecordset("select * from workshift")
rs.addnew
rs![username]= txtUserName.text
rs![timein] = now
rs.update

frmMain.Show

Me.Hide

End If

End If
Data1.Recordset.MoveNext
Loop
If Not LoginSucceeded Then
MsgBox "Invalid UserName/Password, try again!", , "Login"
txtPassword.SetFocus
SendKeys "{Home}+{End}"

Else
Unload Me
End If

End Sub

User is offlineProfile CardPM
+Quote Post

jjsaw5
RE: Time Code
13 Oct, 2008 - 04:16 AM
Post #3

I vill break you
Group Icon

Joined: 4 Jan, 2008
Posts: 1,393



Thanked: 6 times
Dream Kudos: 125
Expert In: HTML, CSS, Database,

My Contributions
@ asanda Please make sure you are using the code tags when you post your code.
User is offlineProfile CardPM
+Quote Post

asanda
RE: Time Code
13 Oct, 2008 - 04:26 AM
Post #4

New D.I.C Head
*

Joined: 6 Oct, 2008
Posts: 5

thanx, I did what you said i should do. and its giving me an error "can't assign to read only property" with a highlight on rs

QUOTE(thava @ 13 Oct, 2008 - 04:29 AM) *

try this
vb

dim Db as database
Private Sub cmdOK_Click()
set db = opendatabase("<your database path here>")
'check for any record, if there is no record there could be error when looping
If Data1.Recordset.RecordCount = 0 Then
MsgBox ("No recordset")
Exit Sub
End If
'check for correct username and password
Data1.Recordset.MoveFirst
Do While Not Data1.Recordset.EOF
If txtUserName = Data1.Recordset.Fields("Username") Then
If txtPassword = Data1.Recordset.Fields("Password") Then
LoginSucceeded = True
set rs = db.openrecordset("select * from workshift")
rs.addnew
rs![username]= txtUserName.text
rs![timein] = now
rs.update

frmMain.Show

Me.Hide

End If

End If
Data1.Recordset.MoveNext
Loop
If Not LoginSucceeded Then
MsgBox "Invalid UserName/Password, try again!", , "Login"
txtPassword.SetFocus
SendKeys "{Home}+{End}"

Else
Unload Me
End If

End Sub



User is offlineProfile CardPM
+Quote Post

asanda
RE: Time Code
13 Oct, 2008 - 04:37 AM
Post #5

New D.I.C Head
*

Joined: 6 Oct, 2008
Posts: 5

QUOTE(jjsaw5 @ 13 Oct, 2008 - 05:16 AM) *

@ asanda Please make sure you are using the code tags when you post your code.



Ok, I'll do that. you'll have to forgive me I'm new to the forum I'm still trying to learn how it works.

Thanx
User is offlineProfile CardPM
+Quote Post

jjsaw5
RE: Time Code
14 Oct, 2008 - 06:57 AM
Post #6

I vill break you
Group Icon

Joined: 4 Jan, 2008
Posts: 1,393



Thanked: 6 times
Dream Kudos: 125
Expert In: HTML, CSS, Database,

My Contributions
QUOTE(asanda @ 13 Oct, 2008 - 08:37 AM) *

QUOTE(jjsaw5 @ 13 Oct, 2008 - 05:16 AM) *

@ asanda Please make sure you are using the code tags when you post your code.



Ok, I'll do that. you'll have to forgive me I'm new to the forum I'm still trying to learn how it works.

Thanx



Not a problem at all. If you have any questions please feel free to PM me.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 03:03AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month