adding records to recordset from treeview selections

Prysson

Registered User.
Local time
Today, 19:01
Joined
Sep 23, 2002
Messages
45
Using the following code to build a recordset

Dim rs As Adodb.Recordset
Dim strEvent As String

Set strEvent = 1
Set rs = New ADODB.Recordset

With rs
.ActiveConnection = CurrentProject.Connection
.CursorLocation = adUseServer
.CursorType = adOpenKeyset
.LockType = adLockPessimistic
.Open "tblJoinEventContactID"
End With



rs.AddNew
rs.Fields("EventID") = strEvent
rs.Fields("ContactID") =

And having a treeview named treeview1 with the property option for checklboxes in use. The treeview Node values are essentially the contactID's

How would I add new records to the recordset using the checked boxes in the treeview assuming that each checked box represents a new record in the recordset.
 
Ok I actually am fairly close...at least I have narrowed down my problem.

It relates to the treeview node, Key parameter.


Conseider this

When I build the nodes for the treeview I use this bit of code

Do While Not rs.EOF
With Me!TreeViewEmployees
.Nodes.Add , , "Employee " & CStr(rs!ContactID) & " Node", rs!Expr1
End With
rs.MoveNext

This basically builds the nodes off of a recordset built prior int he code.

Here is the problem…I don’t want the word Employee nor do I want the word Node in the Key field.
All I want the Key to be is the rs.ContactID but I keep getting the error of invalid Key

How do I add the nodes in the treeview with the key ONLY being the CStr of the rs.ContactID?

I cant figure out the correct syntax.

I know that it needs to read
.Add [Relative][Relationship][Key][Text][Image][SelectedImage}

The first two parmeters are empty because there are no relatives.

But I need to figure out how to have the key be only the value of CStr(rs!ContactID) if I use just that value I get an invalid key error.
 
Figured it out...never mind
 

Users who are viewing this thread

Back
Top Bottom