Results 1 to 4 of 4
  1. #1
    Dave_D's Avatar
    Dave_D is offline Advanced Beginner
    Windows XP Access 2010 64bit
    Join Date
    Aug 2015
    Posts
    67

    Openrecordset issue and duplicate row insertion occuring

    I have 2 issues. I have the following code.

    Dim db As DAO.Database
    Dim rstTemp As DAO.Recordset
    Set db = CurrentDb
    Set rstTemp = db.OpenRecordset("tbl_IssueList",adOpenDynamic)
    'Set rstTemp = db.OpenRecordset("tbl_IssueList")

    rstTemp.AddNew
    rstTemp![Info Type] = Forms![New Issue]![Info Type]
    rstTemp![Entry Date] = [Entry Date]
    rstTemp![Auditor ID] = Forms![New Issue]!AuditorID
    rstTemp!Topic = Topic
    rstTemp!InfoQuestion = InfoQuestion
    rstTemp.Update

    Issue #1 - Whenever I try adding a TYPE (ex. adOpenDynaset) to my db.OpenRecordset SET statement, I get an error of "Invalid argument" Why is that?
    Issue #2 - When I default using TYPE on my SET Statement (2nd one in the code), my table results in 2 entries.



    tbl_IssueList
    ID Info Type Entry Date Auditor ID Topic InfoQuestion Response Date Response Attachments
    90 6/11/2018 Other My Question 0
    91 Question 6/11/2018 DGD001 Other My Question 0

    A. Why do I get 2 results?
    B. Why does only the second entry contain all the data from the forms (NEW ISSUE) entry.

    Both Info Type and Auditor ID are unbound.

    Is there an alternative way to just get a single entry (ID 91) into my table?

    Thank you and any help or suggestions would me appreciated!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    If I had to guess, your form is bound to the table, so it's adding a new record in addition to the code. You want one or the other, not both. The argument normally used is dbOpenDynaset.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Dave_D's Avatar
    Dave_D is offline Advanced Beginner
    Windows XP Access 2010 64bit
    Join Date
    Aug 2015
    Posts
    67
    You were 100% correct and by changing a few to unbound, I managed to insert a single row. Thank you

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Happy to help. For clarity, the form itself should be unbound, as well as the controls with it. That said, bound forms are easier to set up than unbound forms, and don't require code to save records.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Find Duplicate Record Issue....U
    By autiger58 in forum Access
    Replies: 2
    Last Post: 06-20-2017, 10:50 AM
  2. Display Top 3 Re-Occuring Fields in a Report
    By nick404 in forum Reports
    Replies: 8
    Last Post: 06-11-2015, 07:30 AM
  3. Replies: 5
    Last Post: 01-08-2015, 02:08 PM
  4. Replies: 2
    Last Post: 09-25-2013, 12:40 PM
  5. Replies: 1
    Last Post: 10-28-2009, 11:16 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