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

    Red face Unanswered: Help in adding a data..

    Can someone help me with this script..

    Private Sub ClockIn_Click()
    Dim db As DAO.Database
    Dim rs2 As DAO.Recordset

    Set db = CurrentDb
    Set rs2 = db.OpenRecordset("TimeSheet", dbOpenSnapshot)

    rs2.AddNew
    rs2!Empvzid = Me.InputT.Value & "'"
    rs2!TimeIn = Now()
    rs2.Update
    rs2.Close

    Me.InputT.Value = ""

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    If you open a Recordset whith the option dbOpenSnapshot:
    Code:
    Set rs2 = db.OpenRecordset("TimeSheet", dbOpenSnapshot)
    It is read-only and you cannot add to it, delete from it or upate it. Try using:
    Code:
    Set rs2 = db.OpenRecordset("TimeSheet", dbOpenDynaset)
    Note: I'm not sure why you use:
    Code:
    Me.InputT.Value & "'"
    Do you actually want to add a single quote at the end of the value in InputT?
    Have a nice day!

Posting Permissions

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