[CODE]
On Error GoTo ErrorHandler
DoCmd.SetWarnings False
If CodeOldValue = Me.Code Then
If InOutTextOldValue = "In" Then
MsgboxText = "Person just logged in, log the person out again?"
Else
MsgboxText = "Person just logged out, log the person in again?"
End If
response = MsgBox(MsgboxText, vbYesNo)
Else
response = vbYes
End If
If response = vbYes Then
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT infoo.* " _
& "FROM infoo WHERE Code=" & "" & Me.Code & "" & " AND Dated=Date()")
If Not rst.EOF Then
'Has already been log in once today
rst.FindFirst "IsNull([OTime]) "
If rst.NoMatch Then
'Has also logged out again, therefor log in again
Me.TT = "In"
Me.InTime = Now()
rst.AddNew
rst![Code] = Me.Code
rst![Dated] = Me.Dated
rst![InTime] = Me.InTime
rst.Update
InTimeOldValue = Me.InTime
OTimeOldValue = ""
InOutTextOldValue = Me.TT
Else
'Log out
Me.TT = "Out"
Me.InTime = rst![InTime]
Me.OTime = Now()
rst.Edit
rst![OTime] = Me.OTime
rst.Update
OTimeOldValue = Me.OTime
InOutTextOldValue = Me.TT
End If 'Else
Else
'Has not been log in today
Me.TT = "In"
Me.InTime = Now()
rst.AddNew
rst![Code] = Me.Code
rst![Dated] = Me.Dated
rst![InTime] = Me.InTime
rst.Update
InTimeOldValue = Me.InTime
OTimeOldValue = ""
InOutTextOldValue = Me.TT
End If
Else
'The response was no, therefor set the old value back
Me.InTime = InTimeOldValue
Me.OTime = OTimeOldValue
Me.TT = InOutTextOldValue
End If
If Me.TT = "IN" Then
Dim StrSQl As String
Dim Abc As String
Dim p As String
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],'::

AR-E-ARQAM SCHOOL. : Respected Parents!Your Child Has Arrived At School......','Yes',aq);"
DoCmd.RunSQL (StrSQl)
Abc = CStr(Code & ".jpg")
p = "D:\Photo\" & Abc
img11.Picture = p
Else
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:
,'::DAR-E-ARQAM SCHOOL. : Respected Parents! Today Classes Of Your Child is Ended.....','Yes',aq);"
DoCmd.RunSQL (StrSQl)
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
'abc = [GR No]
Abc = CStr(Code & ".jpg")
p = "D:\Photo\" & Abc
img11.Picture = p
End If
CodeOldValue = Me.Code
ExitHandler:
DoCmd.SetWarnings True
Exit Sub
ErrorHandler:
MsgBox Err.Number & Chr(13) & Err.Description
Resume ExitHandler
this query i want to put on after update the field not in forms. when a user update a field this query will be executed every time.