Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2012
    Posts
    8

    Unanswered: not accepting this... if rs!timeout = null then

    I'm in a bit a snag here. Cant seem to do this script... It is always adding a new record instead of updating if there is a record that has no timeout

    Private Sub btnTime_Click()

    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim strCriteria As String
    Dim Last As String
    Dim First As String

    ShowName.Visible = True

    strCriteria = "vzid = '" & Me.txtID.Value & "'"
    Set db = CurrentDb
    Set rs = db.OpenRecordset("LoginT", dbOpenSnapshot)

    rs.FindFirst strCriteria
    If rs.NoMatch = False Then
    Last = rs![LastName] & " " & rs![FirstName]
    Me.ShowName.Caption = Last
    rs.Close
    Set rs = Nothing

    Commando

    Else
    MsgBox ("No Record")

    End If


    End Sub

    Private Sub Commando()

    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim strCriteria As String
    Dim nDate As Date

    nDate = Now()


    Set db = CurrentDb
    Set rs = db.OpenRecordset("TimeSheet", dbOpenDynaset)
    strCriteria = "Empvzid = '" & Me.txtID.Value & "'"

    rs.FindFirst strCriteria
    If rs.NoMatch = False Then

    If rs.Fields("TimeOut") = Null Then
    rs.Edit
    rs![TimeOut] = nDate
    rs.Update
    rs.Close

    Else

    rs.AddNew
    rs![Empvzid] = Me.txtID.Value
    rs![LName] = Me.ShowName.Caption
    rs![TimeIn] = nDate
    rs.Update
    rs.Close

    End If

    Else
    rs.AddNew
    rs![Empvzid] = Me.txtID.Value
    rs![LName] = Me.ShowName.Caption
    rs![TimeIn] = nDate
    rs.Update
    rs.Close


    End If


    End Sub

  2. #2
    Join Date
    Aug 2012
    Posts
    8
    Here is what I got now.. but its still doing addnew after 1 edit on clockout field for one id

    Private Sub btnTime_Click()

    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim strCriteria As String
    Dim Last As String
    Dim First As String

    ShowName.Visible = True

    strCriteria = "vzid = '" & Me.txtID.Value & "'"
    Set db = CurrentDb
    Set rs = db.OpenRecordset("LoginT", dbOpenSnapshot)

    rs.FindFirst strCriteria
    If rs.NoMatch = False Then
    Last = rs![LastName] & " " & rs![FirstName]
    Me.ShowName.Caption = Last
    rs.Close
    Set rs = Nothing

    Commando

    Else
    MsgBox ("No Record")

    End If


    End Sub

    Private Sub Commando()

    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim strCriteria As String
    Dim nDate As Date

    nDate = Now()


    Set db = CurrentDb
    Set rs = db.OpenRecordset("TimeSheet", dbOpenDynaset)
    strCriteria = "Empvzid = '" & Me.txtID.Value & "'"

    rs.FindFirst strCriteria
    If rs.NoMatch = False Then

    If IsNull(rs![TimeOut]) Then
    rs.Edit
    rs![TimeOut] = nDate
    rs.Update
    rs.Close

    Else

    rs.AddNew
    rs![Empvzid] = Me.txtID.Value
    rs![LName] = Me.ShowName.Caption
    rs![TimeIn] = nDate
    rs.Update
    rs.Close


    End If

    Else
    rs.AddNew
    rs![Empvzid] = Me.txtID.Value
    rs![LName] = Me.ShowName.Caption
    rs![TimeIn] = nDate
    rs.Update
    rs.Close


    End If


    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •