By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,069 Members | 1,249 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,069 IT Pros & Developers. It's quick & easy.

have a statement in a vba parent.axcreds.nodes count

100+
P: 462
This is probably a real dumb question but when this statement runs I get an error "Object doesn't support this property or method." I'm at a loss as to why I'm getting this error. I don't find any axcreds anywhere in this database. This is a database I'm trying to convert from an .mdb to a newer version of Access.
Any help is appreciated. If more information is needed let me know.
I don't know what questions to ask. so please don't get mad at me.
In doing more research I find that the OLE Class = TreeCtrl and the Class = MSComctlLib I have no idea where to find this. I'm sure my axcreds are located there, but where are they???
When I converted the .mdb to .accdb it didn't bring across the treectrl tables. I don't know where to locate these tables so don't know how to fix my problem.
May 26 '20 #1
Share this Question
Share on Google+
20 Replies


NeoPa
Expert Mod 15k+
P: 31,761
Hi Tom.

I hear you're struggling to know how to express your situation clearly enough that others will be able to offer assistance. Unfortunately, you're the only feet we have on the ground so we are relying on you to do a decent job. Without knowing more about your problem it's very difficult for us to advise on how better to explain your problem. Call it a Catch-22 if you like.

It still leaves us in the dark & depending on you to give more clarity.
May 27 '20 #2

twinnyfo
Expert Mod 2.5K+
P: 3,482
Tom - could you list the procedure that this code is in?

It also may be an issue with the parent form.

Or it could be as simple as a missing reference (you said you are converting an older DB - You may have missed including the references).

Hope this hepps!
May 27 '20 #3

100+
P: 462
I've been doing more searching and I think what this has to do is with the treectrl When the ctrl was created for student creds however when I converted the .mdb database the treectrl axcreds data didn't come across. I don't know where that data is or how to bring it across to the new .accdb.
The following code is where the error happens. I can send more if need.Thanks
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.     Dim db As Database
  3.     Dim rst As Recordset
  4.     Dim Cred As String
  5.  
  6.     subQB.Form.filter = ""
  7.     subQB.Form.FilterOn = False
  8.  
  9.     Set db = CurrentDb
  10.     Set rst = db.OpenRecordset("SELECT DISTINCTROW Credentials.[Credential Code], Credentials.Description, Credentials.Status, Concerns.Concern, Concerns.ConcernID, Count(QuestionBank.Concern) AS CCount, CredCount.CountOfQuestionNum AS TCount, [CCount]/[TCount] AS CPer " & _
  11.         "FROM (Concerns RIGHT JOIN QuestionBank ON Concerns.ConcernID = QuestionBank.Concern) RIGHT JOIN ((Credentials RIGHT JOIN CredCount ON Credentials.[Credential Code] = CredCount.[Credential Code]) LEFT JOIN TestQuestions ON Credentials.[Credential Code] = TestQuestions.[Credential Code]) ON QuestionBank.QuestionID = TestQuestions.QBNum " & _
  12.         "WHERE (((Credentials.status) < 3)) GROUP BY Credentials.[Credential Code], Credentials.Description, Credentials.Status, Concerns.Concern, Concerns.ConcernID, CredCount.CountOfQuestionNum " & _
  13.         "ORDER BY Credentials.[Credential Code], Concerns.Concern;")
  14.     rst.MoveFirst
  15.     Do
  16.         Cred = rst.Fields("Credential Code")
  17.         If rst.Fields("Status") >= 1 And rst.Fields("Status") <= 2 Then
  18.             axCreds.Nodes.Add , , Cred, Cred & " - " & rst.Fields("Description") & " (" & getCredTot(Cred) & ")", "file"
  19.             Do
  20.                 axCreds.Nodes.Add Cred, tvwChild, Cred & "-" & rst.Fields("ConcernID"), rst.Fields("Concern") & " (" & rst.Fields("CCount") & ")", "blank"
  21.                 rst.MoveNext
  22.                 If rst.EOF Then Exit Do
  23.             Loop Until Cred <> rst.Fields("Credential Code")
  24.         Else
  25.             axBooks.Nodes.Add , , Cred, Cred & " - " & rst.Fields("Description") & " (" & getCredTot(Cred) & ")", "file"
  26.             Do
  27.                 axBooks.Nodes.Add Cred, tvwChild, Cred & "-" & rst.Fields("ConcernID"), rst.Fields("Concern") & " (" & rst.Fields("CCount") & ")", "blank"
  28.                 rst.MoveNext
  29.                 If rst.EOF Then Exit Do
  30.             Loop Until Cred <> rst.Fields("Credential Code")
  31.         End If
  32.     Loop Until rst.EOF
  33.     rst.Close
  34.  
  35.     Set rst = db.OpenRecordset("SELECT T.[Credential Code],Status FROM TestQuestions AS T,Credentials AS C WHERE QBNum=" & subQB.Form.txtQuestionID & " AND T.[Credential Code]=C.[Credential Code] AND C.Status < 3 ORDER BY T.[Credential Code]")
  36.     If rst.EOF = False Then
  37.         rst.MoveFirst
  38.         Do
  39.             If rst.Fields("Status") >= 1 And rst.Fields("Status") <= 2 Then
  40.                 axCreds.Nodes("" & rst.Fields("Credential Code") & "").Image = "used"
  41.                 axCreds.Nodes("" & rst.Fields("Credential Code") & "-" & subQB.Form.cmbConcern & "").Image = "used"
  42.             Else
  43.                 axBooks.Nodes("" & rst.Fields("Credential Code") & "").Image = "used"
  44.                 axBooks.Nodes("" & rst.Fields("Credential Code") & "-" & subQB.Form.cmbConcern & "").Image = "used"
  45.             End If
  46.             rst.MoveNext
  47.         Loop Until rst.EOF
  48.     End If
  49.     rst.Close
  50.     Set db = Nothing
  51. End Sub
May 27 '20 #4

twinnyfo
Expert Mod 2.5K+
P: 3,482
Tom,

I don't see where you've declared axCreds to be anything. You need:
Expand|Select|Wrap|Line Numbers
  1. Dim axCreds As TreeView
before you can do anything with the nodes.

I hope this hepps!
May 27 '20 #5

100+
P: 462
Remember I'm converting this from a .mdb to .accdb I didn't write this program so I would hope that the code would be there. Even if I declare the axcreds where will I find the data that is supposed to be in this table or node.
May 27 '20 #6

twinnyfo
Expert Mod 2.5K+
P: 3,482
Well, one step at a time. We need the system to know what axCreds is first. I also see a User-Defined Function: getCredTot(). You'll need to resolve the obvious issues before you can get into any details.

One method of troubleshooting I sometimes use (when importing huge chunks of code is to comment out the entire block and then uncomment one line at a time and compile. If there is an If...Then statement (or other nested set of lines) I uncomment the first and last lines, then go through each line inside.

This make take you some time to figure out what exactly is missing, as there may be multiple issues--you're just getting one error on one thing.
May 27 '20 #7

100+
P: 462
I've added the Dim axCreds as treeview, I also made sure I have the activex control Microsoft treeview control. It still stops on the statement Me.parent.axCreds.nodes.count Not sure where to go from here.
May 27 '20 #8

100+
P: 462
When I press Ok on that statement the form comes up but I don't have the data in the axCreds sub form.
May 27 '20 #9

twinnyfo
Expert Mod 2.5K+
P: 3,482
Tom,

Please try to help us out here. The statement "Me.parent.axCreds.nodes.count" is not in the code you provided.
May 27 '20 #10

100+
P: 462
Sorry, here's the code
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.     Dim db As Database
  3.     Dim rst As Recordset
  4.     Dim i As Integer
  5.     Dim tNode As Object
  6.     Dim axCreds As TreeView
  7. If ignore = False Then
  8.     If IsNull(txtQuestionID) And delInProg = False Then
  9.         setEdit True
  10.     Else
  11.         setEdit False
  12.     End If
  13.     If Me.Parent.Name = "ExamCreate" And IsNull(txtQuestionID) = False Then
  14.         Set db = CurrentDb
  15.         Set rst = db.OpenRecordset("SELECT * FROM TestQuestions WHERE [Credential Code]='" & Me.Parent.lstCred & "' AND QBNum=" & txtQuestionID)
  16.         If rst.EOF Then
  17.             Me.Parent.chkInc.Value = False
  18.             Me.Parent.chkSeed.Enabled = False
  19.             Me.Parent.chkSeed.Value = False
  20.         Else
  21.             Me.Parent.chkInc.Value = True
  22.             Me.Parent.chkSeed.Enabled = True
  23.             Me.Parent.chkSeed.Value = rst.Fields("SeedQuestion")
  24.         End If
  25.         rst.Close
  26.         Set db = Nothing
  27.     ElseIf Me.Parent.Name = "QBPlus" Then
  28. 'Me.Parent.Form.axCreds.Nodes
  29.         If Me.Parent.axCreds.Nodes.count > 0 And Form.RecordsetClone.RecordCount > 0 Then
  30.             For i = 1 To Me.Parent.axCreds.Nodes.count
  31.                 If InStr(Me.Parent.axCreds.Nodes(i).key, "-") Then
  32.                     Me.Parent.axCreds.Nodes(i).Image = "blank"
  33.                 Else
  34.                     Me.Parent.axCreds.Nodes(i).Image = "file"
  35.                 End If
  36.             Next
  37.             For i = 1 To Me.Parent.axBooks.Nodes.count
  38.                 If InStr(Me.Parent.axBooks.Nodes(i).key, "-") Then
  39.                     Me.Parent.axBooks.Nodes(i).Image = "blank"
  40.                 Else
  41.                     Me.Parent.axBooks.Nodes(i).Image = "file"
  42.                 End If
  43.             Next
  44.  
  45.             If IsNull(txtQuestionID) Then Exit Sub
  46.  
  47.             Set db = CurrentDb
  48.             Set rst = db.OpenRecordset("SELECT T.[Credential Code],Status FROM TestQuestions AS T,Credentials AS C WHERE QBNum=" & txtQuestionID & " AND T.[Credential Code]=C.[Credential Code] AND C.Status < 3 ORDER BY T.[Credential Code]")
  49.             If rst.EOF = False Then
  50.                 rst.MoveFirst
  51.                 Do
  52.                     If rst.Fields("Status") <> 0 Then
  53.                         Me.Parent.axCreds.Nodes("" & rst.Fields("Credential Code") & "").Image = "used"
  54.                         Me.Parent.axCreds.Nodes("" & rst.Fields("Credential Code") & "-" & cmbConcern & "").Image = "used"
  55.                     Else
  56.                         Me.Parent.axBooks.Nodes("" & rst.Fields("Credential Code") & "").Image = "used"
  57.                         Me.Parent.axBooks.Nodes("" & rst.Fields("Credential Code") & "-" & cmbConcern & "").Image = "used"
  58.                     End If
  59.                     rst.MoveNext
  60.                 Loop Until rst.EOF
  61.             End If
  62.             rst.Close
  63.             Set db = Nothing
  64.  
  65.             Set tNode = Me.Parent.axCreds.Object.SelectedItem
  66.             If Not tNode Is Nothing Then
  67.                 If tNode.Image = "used" Then
  68.                     Me.Parent.cmdAdd.Enabled = False
  69.                     Me.Parent.cmdDel.Enabled = True
  70.                 Else
  71.                     Me.Parent.cmdAdd.Enabled = True
  72.                     Me.Parent.cmdDel.Enabled = False
  73.                 End If
  74.             Else
  75.                 Set tNode = Me.Parent.axBooks.Object.SelectedItem
  76.                 If Not tNode Is Nothing Then
  77.                     If tNode.Image = "used" Then
  78.                         Me.Parent.cmdAdd.Enabled = False
  79.                         Me.Parent.cmdDel.Enabled = True
  80.                     Else
  81.                         Me.Parent.cmdAdd.Enabled = True
  82.                         Me.Parent.cmdDel.Enabled = False
  83.                     End If
  84.                 End If
  85.             End If
  86.             Set tNode = Nothing
  87.         End If
  88.     End If
  89. End If
  90.  
  91. End Sub
May 27 '20 #11

twinnyfo
Expert Mod 2.5K+
P: 3,482
You also need to set the variable of axCreds to the TreeView control that you are using. I am having no issues accessing the count properties of the TreeView Nodes.

There seems to be much more missing from the VBA you've posted than what we can work with. The "Parent" indicates that your Form is a Subform on another form. The code you posted previously also indicates that there may be a subform on the form you are looking at.

Again, you are going to have to tackle this one small step at a time. It appears much of what is being referenced is not present.
May 27 '20 #12

100+
P: 462
In the code I just posted the parent form is QBPlus line 27. I've also removed the ' from line 28 and the program stops on the line also.
May 27 '20 #13

twinnyfo
Expert Mod 2.5K+
P: 3,482
I still think we are chasing our tails by staying in this form. The issue is stemming from the parent. There may be issues there that need to be fixed before you can address them here on this form. Is this approach to troubleshooting making any sense, yet?

The error has always pointed to the parent form (note my second statement in Post #3). This is where you need to start.
May 27 '20 #14

100+
P: 462
I've checked references and don't see any missing.
I've never worked with a program that has tree ctrl. How this one works is there is a main menu, with select buttons, the one where we get the error is "Question form" that procedure calls
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "QBPlus"
following that the next code is
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2.     Dim db As Database
  3.     Dim rst As Recordset
  4.     Set db = CurrentDb
  5.     Set rst = db.OpenRecordset("SELECT * FROM QuestionBank")
  6.     If rst.EOF Then
  7.         Me.Caption = "QuestionBank - Add"
  8.         setEdit True
  9.     End If
  10.     rst.Close
  11.     db.Close
  12.  
  13.     ignore = False
  14. End Sub
The Questionbank is not eof, after that runs if jumps to
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.     Dim db As Database
  3.     Dim rst As Recordset
  4.     Dim i As Integer
  5.     Dim tNode As Object
  6.     Dim axCreds As TreeView
  7. If ignore = False Then
  8.     If IsNull(txtQuestionID) And delInProg = False Then
  9.         setEdit True
  10.     Else
  11.         setEdit False
  12.     End If
  13.     If Me.Parent.Name = "ExamCreate" And IsNull(txtQuestionID) = False Then
  14.         Set db = CurrentDb
  15.         Set rst = db.OpenRecordset("SELECT * FROM TestQuestions WHERE [Credential Code]='" & Me.Parent.lstCred & "' AND QBNum=" & txtQuestionID)
  16.         If rst.EOF Then
  17.             Me.Parent.chkInc.Value = False
  18.             Me.Parent.chkSeed.Enabled = False
  19.             Me.Parent.chkSeed.Value = False
  20.         Else
  21.             Me.Parent.chkInc.Value = True
  22.             Me.Parent.chkSeed.Enabled = True
  23.             Me.Parent.chkSeed.Value = rst.Fields("SeedQuestion")
  24.         End If
  25.         rst.Close
  26.         Set db = Nothing
  27.     ElseIf Me.Parent.Name = "QBPlus" Then
  28. 'Me.Parent.Form.axCreds.Nodes
  29.         If Me.Parent.axCreds.Nodes.count > 0 And Form.RecordsetClone.RecordCount > 0 Then
  30.             For i = 1 To Me.Parent.axCreds.Nodes.count
  31.                 If InStr(Me.Parent.axCreds.Nodes(i).key, "-") Then
  32.                     Me.Parent.axCreds.Nodes(i).Image = "blank"
  33.                 Else
  34.                     Me.Parent.axCreds.Nodes(i).Image = "file"
  35.                 End If
  36.             Next
  37.             For i = 1 To Me.Parent.axBooks.Nodes.count
  38.                 If InStr(Me.Parent.axBooks.Nodes(i).key, "-") Then
  39.                     Me.Parent.axBooks.Nodes(i).Image = "blank"
  40.                 Else
  41.                     Me.Parent.axBooks.Nodes(i).Image = "file"
  42.                 End If
  43.             Next
  44.  
  45.             If IsNull(txtQuestionID) Then Exit Sub
  46.  
  47.             Set db = CurrentDb
  48.             Set rst = db.OpenRecordset("SELECT T.[Credential Code],Status FROM TestQuestions AS T,Credentials AS C WHERE QBNum=" & txtQuestionID & " AND T.[Credential Code]=C.[Credential Code] AND C.Status < 3 ORDER BY T.[Credential Code]")
  49.             If rst.EOF = False Then
  50.                 rst.MoveFirst
  51.                 Do
  52.                     If rst.Fields("Status") <> 0 Then
  53.                         Me.Parent.axCreds.Nodes("" & rst.Fields("Credential Code") & "").Image = "used"
  54.                         Me.Parent.axCreds.Nodes("" & rst.Fields("Credential Code") & "-" & cmbConcern & "").Image = "used"
  55.                     Else
  56.                         Me.Parent.axBooks.Nodes("" & rst.Fields("Credential Code") & "").Image = "used"
  57.                         Me.Parent.axBooks.Nodes("" & rst.Fields("Credential Code") & "-" & cmbConcern & "").Image = "used"
  58.                     End If
  59.                     rst.MoveNext
  60.                 Loop Until rst.EOF
  61.             End If
  62.             rst.Close
  63.             Set db = Nothing
  64.  
  65.             Set tNode = Me.Parent.axCreds.Object.SelectedItem
  66.             If Not tNode Is Nothing Then
  67.                 If tNode.Image = "used" Then
  68.                     Me.Parent.cmdAdd.Enabled = False
  69.                     Me.Parent.cmdDel.Enabled = True
  70.                 Else
  71.                     Me.Parent.cmdAdd.Enabled = True
  72.                     Me.Parent.cmdDel.Enabled = False
  73.                 End If
  74.             Else
  75.                 Set tNode = Me.Parent.axBooks.Object.SelectedItem
  76.                 If Not tNode Is Nothing Then
  77.                     If tNode.Image = "used" Then
  78.                         Me.Parent.cmdAdd.Enabled = False
  79.                         Me.Parent.cmdDel.Enabled = True
  80.                     Else
  81.                         Me.Parent.cmdAdd.Enabled = True
  82.                         Me.Parent.cmdDel.Enabled = False
  83.                     End If
  84.                 End If
  85.             End If
  86.             Set tNode = Nothing
  87.         End If
  88.     End If
  89. End If
  90.  
  91. End Sub
The code line setEdit false runs code
Expand|Select|Wrap|Line Numbers
  1. Public Sub setEdit(trigger As Boolean)
  2.     txtAnswer.Locked = Not trigger
  3.     txtQuestionStr.Locked = Not trigger
  4.     txtQuestionStr.SetFocus
  5.     subQuestionChoices.Locked = Not trigger
  6.     cmbTest.Locked = Not trigger
  7.     cmbConcern.Locked = Not trigger
  8.     cmdConcernAdd.Visible = trigger
  9.     If Me.Parent.Name <> "ExamCreate" Then
  10.         cmdAdd.Visible = Not trigger
  11.         lblAdd.Visible = Not trigger
  12.         cmdUpd.Visible = Not trigger
  13.         lblUpd.Visible = Not trigger
  14.         cmdDel.Visible = Not trigger
  15.         lblDel.Visible = Not trigger
  16.         cmdPic.Visible = trigger
  17.         lblPic.Visible = trigger
  18.     Else
  19.         Me.Parent.cmdAdd.Visible = Not trigger
  20.         Me.Parent.lblAdd.Visible = Not trigger
  21.         Me.Parent.cmdUpd.Visible = Not trigger
  22.         Me.Parent.lblUpd.Visible = Not trigger
  23.         Me.Parent.cmdExch.Visible = Not trigger
  24.         Me.Parent.lblExch.Visible = Not trigger
  25.         cmdPic.Visible = trigger
  26.         lblPic.Visible = trigger
  27.         Me.Parent.subQB.Locked = Not trigger
  28.     End If
  29.     cmdConfirm.Visible = trigger
  30.     If trigger Then
  31.         If IsNull(txtQuestionID) Then
  32.             cmdCancel.Visible = True
  33.         Else
  34.             cmdCancel.Visible = False
  35.         End If
  36.     Else
  37.         cmdCancel.Visible = False
  38.     End If
  39. End Sub
and then we hit the axCreds and get the error.
I don't know if this helps or not.
May 27 '20 #15

twinnyfo
Expert Mod 2.5K+
P: 3,482
Tom,

I still think you are approaching this from "the whole thing."

You need to begin with each small step:

Recreate the main form
Add the minimal amount of Code to open and close that form without a hitch.
Gradually add controls to your form
Add code for the controls
Add the TreeView control
Gradually add parts of the code to add functionality to the TreeView control
etc.

I still think this is a referencing problem. Either the control is not declared, set or referenced properly.

Again, in two minutes, I created a form with a TreeView control, dimmed a TreeView, set that object to the control, and was able to access all properties. Everything is there. I think you're just biting off more than you can chew at one time.

One step at a time--not many of us here have the time to work through "the whole thing." We are trying to point you toward where to focus your troubleshooting.

The nature of the error has to do with proper referencing. The code does not understand that the object is a TreeView control. It's that simple. That's the answer. You need to find out why it is not declared that way. I think there may be a module somewhere that is declaring it and setting it so publicly, but the code provided doesn't mention it anywhere. Once that public bit is uncovered, you will find success.
May 27 '20 #16

100+
P: 462
One more questions and then I'll continue with the step by stem. Where is the data kept for a tree ctrl or node. That's the part I don't understand. Is this tree ctrl or tree view like a table with columns and rows? and if so can I edit this like a table.
May 27 '20 #17

twinnyfo
Expert Mod 2.5K+
P: 3,482
Usually a TreeView is filled "from somewhere." Usually from a Table. The user interacts with the tree view to manipulate the data in the table.

NB: I have not used TreeView controls, but an object-based language like VBA will treat it like any other object.
May 27 '20 #18

NeoPa
Expert Mod 15k+
P: 31,761
First I must congratulate Twinny for showing such patience. Above & beyond in my view.

As for a TreeView control, like Twinny I've heard of them, and seen themn in action, but I've never got my hands dirty with them at all. Nevertheless, in all the objects I've dealt with in Access that manage data there's a consistency to how the data is specified.

Forms & Repords have a RecordSource property and Controls have a ControlSource property. Have you looked to see if the TreeView Control has such a property? If so what is it set to, if anything?
May 28 '20 #19

twinnyfo
Expert Mod 2.5K+
P: 3,482
TreeViews do not have a record source.
May 28 '20 #20

NeoPa
Expert Mod 15k+
P: 31,761
So it doesn't. Well, that's weird. I'd ask how it gets populated but that might allow the thread to be side-tracked so I won't here.
Jun 4 '20 #21

Post your reply

Sign in to post your reply or Sign up for a free account.