Results 1 to 2 of 2
  1. #1
    shah1419 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jan 2013
    Posts
    30

    post update item(field)

    [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.

  2. #2
    shah1419 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jan 2013
    Posts
    30

    Admin

    Quote Originally Posted by shah1419 View Post
    [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.
    [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:
    ")
    Code:
    StrSQl = "Insert into MsgOut(iid,msg,send,msgto) Values ('::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 Code:
    ,
    Resume ExitHandler

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 04-05-2018, 05:03 AM
  2. Locating last item in a field
    By George in forum Modules
    Replies: 4
    Last Post: 08-15-2017, 06:54 PM
  3. Standalone Access licence post Win10 Update
    By MoodyPD in forum Access
    Replies: 0
    Last Post: 01-07-2016, 01:39 PM
  4. Replies: 7
    Last Post: 11-29-2015, 07:24 AM
  5. newbie post - why can't I update a field from openargs
    By Turncloud in forum Programming
    Replies: 1
    Last Post: 09-10-2013, 07:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums