outtime of employee not update

sahh1419

Registered User.
Local time
Today, 20:07
Joined
Dec 27, 2012
Messages
29
I want to record emp in and out time. i have attached the form with this query. The structure of table is:
Code Text
Intime Date/Time
Otime Date/Time
Dated Date
-----------------------------------------------------
When i put code (e.g 1569) in code field it will track only intime nd when i put this code second time it will show only intime and cannot save the otime entry.
The 2nd problem is i only want it will shows this message:
You are about to append 1 row(s) ......Yess.......NO
-----------------------------------------------------------------
Here is the VBA Code:
Option Compare Database
Dim abc As String
Dim p As String
Dim aa As String
Dim strSQl As String
-----------------------------------------------------------------
Private Sub Code_AfterUpdate()
If Not (Intime) And (Dated) Then
If IsNull(Otime) And Otime = "" And Code = Code Then
Me.Otime = Now()
Me.T = DLookup("Name", "Student", "[GR No]=
Code:
")
Me.aq = DLookup("Mobile", "Student", "[GR No]=[Code]")
strSQl = "Insert into MsgOut(iid,msg,send,msgto) Values ([code],'Today Classes Of Your Child is Ended...','Yes',aq);"
DoCmd.RunSQL (strSQl)
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
End If
End If
'abc = [GR No]
abc = CStr(Code & ".jpg")
p = "D:\Photo\" & abc
img11.Picture = p
If IsNull(Otime) Then
tt = "IN"
End If
End Sub
+----------------------------------------------------------
Private Sub Code_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
Me.T = DLookup("Name", "Student", "[GR No]=[Code]")
Me.aq = DLookup("Mobile", "Student", "[GR No]=[Code]")
strSQl = "Insert into MsgOut(iid,msg,send,msgto) Values ([code],'Your Child Has Arrived At School..','Yes',aq);"
DoCmd.RunSQL (strSQl)
' DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
End If
abc = CStr(Code & ".jpg")
p = "D:\Photo\" & abc
img11.Picture = p
If Not IsNull(Intime) And (Dated) Then
tt = "OUT"
End If
End Sub
----------------------------------------
Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec
Me.Intime = Now()
Me.Dated = Date
Me.Otime = ""
End Sub
---------------
pls help me in this regards
 

Attachments

  • 1.jpg
    1.jpg
    97.8 KB · Views: 120
Code:
If IsNull(Otime) And Otime = ""  ...  Then
Otime can only bee once at a time! So to get into the if statements you have to use "OR"
Code:
If IsNull(Otime) OR Otime = "" ....  Then
Code:
Code = Code
Why do you have this?
"Code" will always be equal "Code"
To refer to a control it is a good practice to use "Me", like "Me.Otime"
 
i have made some changes which you mention in reply. but in and out time is occur at the same time.When i put a code in "code" textbox it fills the "Me.intime" and "Me.otime" same time.please view at the attached file.
i only want the event procedure will check the code in database wether this code is present in the current date list and otime is null then it will fill only otime, when code is equal to the code present in the table.
 

Attachments

  • 3.jpg
    3.jpg
    96.5 KB · Views: 119
Do you post your changes code?
 
Here is the code.Please check its event wether is correct or not????
--------------------------------------------------------------
Option Compare Database
Dim abc As String
Dim p As String
Dim aa As String
Dim strSQl As String
-----------------------------------------------------------------
Private Sub Code_AfterUpdate()
On Error GoTo ErrorHandler
DoCmd.SetWarnings False
If Not (Me.Intime) And (Me.Dated) Then
If IsNull(Me.Otime) Or Code = Code Then
Me.Otime = Now()
Me.T = DLookup("Name", "Student", "[GR No]=
Code:
")
   Me.aq = DLookup("Mobile", "Student", "[GR No]=[Code]")
   strSQl = "Insert into MsgOut(iid,msg,send,msgto) Values ([code],'Today Classes Of Your Child is Ended...','Yes',aq);"
   DoCmd.RunSQL (strSQl)
     DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
  End If
   End If
       'abc = [GR No]
abc = CStr(Code & ".jpg")
p = "D:\Photo\" & abc
img11.Picture = p
If Not IsNull(Me.Otime) Then
  tt = "OUT"
   End If
ExitHandler:
    DoCmd.SetWarnings True
    Exit Sub
ErrorHandler:
    MsgBox Err.Number & Chr(13) & Err.Description
    Resume ExitHandler
End Sub
----------------------------------------------------------
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo ErrorHandler
    DoCmd.SetWarnings False
If Me.NewRecord Then
   Me.T = DLookup("Name", "Student", "[GR No]=[Code]")
   Me.aq = DLookup("Mobile", "Student", "[GR No]=[Code]")
   strSQl = "Insert into MsgOut(iid,msg,send,msgto) Values ([code],'Your Child Has Arrived At School..','Yes',aq);"
   DoCmd.RunSQL (strSQl)
      End If
    abc = CStr(Code & ".jpg")
   p = "D:\Photo\" & abc
   img11.Picture = p
   If Not IsNull(Me.Intime) And (Me.Dated) Then
   tt = "IN"
  End If
ExitHandler:
    DoCmd.SetWarnings True
    Exit Sub
ErrorHandler:
    MsgBox Err.Number & Chr(13) & Err.Description
    Resume ExitHandler
End Sub
 
-----------------------------------------------------
Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec
Me.Intime = Now()
Me.Dated = Date
Me.Otime = ""
End Sub

 
Please advised how i can get intime first time and get otime after repeat.
 
No intime and outtime isn't the same it is 3 seconds between them.
(I'll recommend you to set the error handling out of function until your code runs ok.)
Also set the DoCmd.SetWarnings False out of function.

And place "Option Explicit" in top of the module, then you get warnings if you are using undeclared variables.
Code:
  Option Compare Database
  Option Explicit
I still don't understand this "Code = Code".
Code compare themselves with themselves and will always be true and equal. :)
 
i placed Option Explicit on top of module. now it records only intime and do nothing (not record otime).please check wether the event ocde is correct or not.

For code i compare when intime is saved in table with code and next time code will eneter it will compare in the table to find the code and assign otime.

please davised.
 
For code i compare when intime is saved in table with code and next time code will eneter it will compare in the table to find the code and assign otime.
Sorry - no it will not! :)
Code:
If IsNull(Me.Otime) Or Code = Code Then
Here the code looks if "Code=Code". If Control with the name "Code" is equal to the Control with the name "Code".:)
If you type in number 8 in the "Code" it will compare if 8=8, or if you type in number 11 in the "Code" it will compare if 11=11.:)

I think we have to start from new. Could you in detail explain what you want the form to do and when. (I know you want to record emp in and out time, but take it step for step, when do they lock in, when do they lock out and so on).
 
Step-1:
On Form Load Event Control
Code:
,Intime,Otime,Dated will be empty.
Step-2:
When User Put Code in control [COLOR=darkred][B]e.g. 8.[/B][/COLOR] it will shows its picture, intime, dated. Otime will be null.
Step-3:
When user again put the same above code ([B][COLOR=#8b0000]e.g. 8) in control. it will check its intime,dated(current date) exist or not. if intime exist the otime will be filled with time.[/COLOR][/B]
[B][COLOR=#8b0000]Step-4:[/COLOR][/B]
[B][COLOR=#8b0000]When user again put code in control the emp will be in and his intime will be recorded.[/COLOR][/B]
 
[B][COLOR=#8b0000]please advised if you need more info.[/COLOR][/B]
 
Then you need to use an unbound formular, I've made an example for you, which I send in the attached database.
 

Attachments

i will see it would be nice..thx in advane. i will put this code into my database and advised you.
Bundles Of Thanks. It works................

regards
 
Last edited:

Users who are viewing this thread

Back
Top Bottom