Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / September 2007

Tip: Looking for answers? Try searching our database.

Treeview error 35602 in Access 2007

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Radtherapy - 25 Sep 2007 15:02 GMT
Whenever I try to populate my Treeview control, I get an error 35602 "Key is
not unique in collection".  The table I am populating from has 1 record and
the primary key is an autonumber.  Here is the code:

Private Sub FavMenu()
'This procedure populates the TreeView control for User's Favorite Items
   On Error GoTo ErrFavMenu

   Dim db As Database
   Dim rstf As Recordset
   Dim nodfCurrent As Node, nodfRoot As Node
   Dim objfTree As TreeView
   Dim strfText As String, bk As String, strfRecSet As String

   strfRecSet = "SELECT DISTINCT MenuSubID, SubTitle, ActiveOpt FROM
tblExecMenuFavs where UserID = " & glbUserID & " ORDER BY SubTitle"
   Set db = CurrentDb
   Set rstf = db.OpenRecordset(strfRecSet, dbOpenDynaset, dbSeeChanges)
   Set objfTree = Me.xTreeFav.Object
   Me!xTreeFav.Font = "Franklin Gothic Medium"
   Me!xTreeFav.Font.Size = "11"
   While (Not rstf.EOF)
       strfText = rstf![SubTitle]
       Set nodfCurrent = objfTree.Nodes.Add(, , "k" & rstf("MenuSubID"),
strfText)
       rstf.MoveNext
   Wend

ExitFavMenu:
   rstf.Close
   Set rstf = Nothing
   
   Exit Sub

ErrFavMenu:
   If Err.Number = 35602 Then
       MsgBox Err.Number & " " & Err.Description
       Resume Next
   Else
       MsgBox Err.Number & " " & Err.Description, vbCritical, "Form_Load"
       Resume ExitFavMenu
   End If
End Sub

This happened to me once before a few months ago, and I absolutely cannot
remember what I had to do to fix it - any help and I promise I will write the
solution down and store it in a locked vault.

Thanks.
Alex Dybenko - 27 Sep 2007 13:10 GMT
Hi,
perhaps you already have a node with such key, try to clear all nodes before
filling:
Set objfTree = Me.xTreeFav.Object
objfTree.nodes.clear

Signature

Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

> Whenever I try to populate my Treeview control, I get an error 35602 "Key
> is
[quoted text clipped - 48 lines]
>
> Thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.