troubleshooting Question

Error occurs when trying to add multiple records to one recordset

Avatar of angie_angie
angie_angie asked on
Microsoft AccessVisual Basic.NET
8 Comments1 Solution404 ViewsLast Modified:
I got error message saying that duplicate entries are not allowed when I tried to add 3 records to one recordset. But it works fine with just one record.

Here are the codes:

    lookFor = "aa"
    value = DLookup("[F2]", "Table", "[F1] = '" & lookFor & "'")
    rdAdd.Open "AssetInfo", CurrentProject.Connection, addOpenKeyset, adLockOptimistic
      With rdAdd
      .AddNew
      rdAdd("AA") = value
      .Update
      End With
     
    lookFor = "bb"
    value = DLookup("[F2]", "Table", "[F1] = '" & lookFor & "'")
      With rdAdd
      .AddNew
      rdAdd("BB") = value
      .Update
      End With
     
    lookFor = "cc"
    value = DLookup("[F2]", "Table", "[F1] = '" & lookFor & "'")
      With rdAdd
      .AddNew
      rdAdd("CC") = value
      .Update
      .Close
      End With
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros