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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CD Tom
    Contributor
    • Feb 2009
    • 495

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

    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.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32633

    #2
    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.

    Comment

    • twinnyfo
      Recognized Expert Moderator Specialist
      • Nov 2011
      • 3653

      #3
      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!

      Comment

      • CD Tom
        Contributor
        • Feb 2009
        • 495

        #4
        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
        Code:
        Private Sub Form_Load()
            Dim db As Database
            Dim rst As Recordset
            Dim Cred As String
            
            subQB.Form.filter = ""
            subQB.Form.FilterOn = False
            
            Set db = CurrentDb
            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 " & _
                "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 " & _
                "WHERE (((Credentials.status) < 3)) GROUP BY Credentials.[Credential Code], Credentials.Description, Credentials.Status, Concerns.Concern, Concerns.ConcernID, CredCount.CountOfQuestionNum " & _
                "ORDER BY Credentials.[Credential Code], Concerns.Concern;")
            rst.MoveFirst
            Do
                Cred = rst.Fields("Credential Code")
                If rst.Fields("Status") >= 1 And rst.Fields("Status") <= 2 Then
                    axCreds.Nodes.Add , , Cred, Cred & " - " & rst.Fields("Description") & " (" & getCredTot(Cred) & ")", "file"
                    Do
                        axCreds.Nodes.Add Cred, tvwChild, Cred & "-" & rst.Fields("ConcernID"), rst.Fields("Concern") & " (" & rst.Fields("CCount") & ")", "blank"
                        rst.MoveNext
                        If rst.EOF Then Exit Do
                    Loop Until Cred <> rst.Fields("Credential Code")
                Else
                    axBooks.Nodes.Add , , Cred, Cred & " - " & rst.Fields("Description") & " (" & getCredTot(Cred) & ")", "file"
                    Do
                        axBooks.Nodes.Add Cred, tvwChild, Cred & "-" & rst.Fields("ConcernID"), rst.Fields("Concern") & " (" & rst.Fields("CCount") & ")", "blank"
                        rst.MoveNext
                        If rst.EOF Then Exit Do
                    Loop Until Cred <> rst.Fields("Credential Code")
                End If
            Loop Until rst.EOF
            rst.Close
              
            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]")
            If rst.EOF = False Then
                rst.MoveFirst
                Do
                    If rst.Fields("Status") >= 1 And rst.Fields("Status") <= 2 Then
                        axCreds.Nodes("" & rst.Fields("Credential Code") & "").Image = "used"
                        axCreds.Nodes("" & rst.Fields("Credential Code") & "-" & subQB.Form.cmbConcern & "").Image = "used"
                    Else
                        axBooks.Nodes("" & rst.Fields("Credential Code") & "").Image = "used"
                        axBooks.Nodes("" & rst.Fields("Credential Code") & "-" & subQB.Form.cmbConcern & "").Image = "used"
                    End If
                    rst.MoveNext
                Loop Until rst.EOF
            End If
            rst.Close
            Set db = Nothing
        End Sub

        Comment

        • twinnyfo
          Recognized Expert Moderator Specialist
          • Nov 2011
          • 3653

          #5
          Tom,

          I don't see where you've declared axCreds to be anything. You need:
          Code:
          Dim axCreds As TreeView
          before you can do anything with the nodes.

          I hope this hepps!

          Comment

          • CD Tom
            Contributor
            • Feb 2009
            • 495

            #6
            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.

            Comment

            • twinnyfo
              Recognized Expert Moderator Specialist
              • Nov 2011
              • 3653

              #7
              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.

              Comment

              • CD Tom
                Contributor
                • Feb 2009
                • 495

                #8
                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.axCre ds.nodes.count Not sure where to go from here.

                Comment

                • CD Tom
                  Contributor
                  • Feb 2009
                  • 495

                  #9
                  When I press Ok on that statement the form comes up but I don't have the data in the axCreds sub form.

                  Comment

                  • twinnyfo
                    Recognized Expert Moderator Specialist
                    • Nov 2011
                    • 3653

                    #10
                    Tom,

                    Please try to help us out here. The statement "Me.parent.axCr eds.nodes.count " is not in the code you provided.

                    Comment

                    • CD Tom
                      Contributor
                      • Feb 2009
                      • 495

                      #11
                      Sorry, here's the code
                      Code:
                      Private Sub Form_Current()
                          Dim db As Database
                          Dim rst As Recordset
                          Dim i As Integer
                          Dim tNode As Object
                          Dim axCreds As TreeView
                      If ignore = False Then
                          If IsNull(txtQuestionID) And delInProg = False Then
                              setEdit True
                          Else
                              setEdit False
                          End If
                          If Me.Parent.Name = "ExamCreate" And IsNull(txtQuestionID) = False Then
                              Set db = CurrentDb
                              Set rst = db.OpenRecordset("SELECT * FROM TestQuestions WHERE [Credential Code]='" & Me.Parent.lstCred & "' AND QBNum=" & txtQuestionID)
                              If rst.EOF Then
                                  Me.Parent.chkInc.Value = False
                                  Me.Parent.chkSeed.Enabled = False
                                  Me.Parent.chkSeed.Value = False
                              Else
                                  Me.Parent.chkInc.Value = True
                                  Me.Parent.chkSeed.Enabled = True
                                  Me.Parent.chkSeed.Value = rst.Fields("SeedQuestion")
                              End If
                              rst.Close
                              Set db = Nothing
                          ElseIf Me.Parent.Name = "QBPlus" Then
                      'Me.Parent.Form.axCreds.Nodes
                              If Me.Parent.axCreds.Nodes.count > 0 And Form.RecordsetClone.RecordCount > 0 Then
                                  For i = 1 To Me.Parent.axCreds.Nodes.count
                                      If InStr(Me.Parent.axCreds.Nodes(i).key, "-") Then
                                          Me.Parent.axCreds.Nodes(i).Image = "blank"
                                      Else
                                          Me.Parent.axCreds.Nodes(i).Image = "file"
                                      End If
                                  Next
                                  For i = 1 To Me.Parent.axBooks.Nodes.count
                                      If InStr(Me.Parent.axBooks.Nodes(i).key, "-") Then
                                          Me.Parent.axBooks.Nodes(i).Image = "blank"
                                      Else
                                          Me.Parent.axBooks.Nodes(i).Image = "file"
                                      End If
                                  Next
                                  
                                  If IsNull(txtQuestionID) Then Exit Sub
                                  
                                  Set db = CurrentDb
                                  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]")
                                  If rst.EOF = False Then
                                      rst.MoveFirst
                                      Do
                                          If rst.Fields("Status") <> 0 Then
                                              Me.Parent.axCreds.Nodes("" & rst.Fields("Credential Code") & "").Image = "used"
                                              Me.Parent.axCreds.Nodes("" & rst.Fields("Credential Code") & "-" & cmbConcern & "").Image = "used"
                                          Else
                                              Me.Parent.axBooks.Nodes("" & rst.Fields("Credential Code") & "").Image = "used"
                                              Me.Parent.axBooks.Nodes("" & rst.Fields("Credential Code") & "-" & cmbConcern & "").Image = "used"
                                          End If
                                          rst.MoveNext
                                      Loop Until rst.EOF
                                  End If
                                  rst.Close
                                  Set db = Nothing
                                  
                                  Set tNode = Me.Parent.axCreds.Object.SelectedItem
                                  If Not tNode Is Nothing Then
                                      If tNode.Image = "used" Then
                                          Me.Parent.cmdAdd.Enabled = False
                                          Me.Parent.cmdDel.Enabled = True
                                      Else
                                          Me.Parent.cmdAdd.Enabled = True
                                          Me.Parent.cmdDel.Enabled = False
                                      End If
                                  Else
                                      Set tNode = Me.Parent.axBooks.Object.SelectedItem
                                      If Not tNode Is Nothing Then
                                          If tNode.Image = "used" Then
                                              Me.Parent.cmdAdd.Enabled = False
                                              Me.Parent.cmdDel.Enabled = True
                                          Else
                                              Me.Parent.cmdAdd.Enabled = True
                                              Me.Parent.cmdDel.Enabled = False
                                          End If
                                      End If
                                  End If
                                  Set tNode = Nothing
                              End If
                          End If
                      End If
                          
                      End Sub

                      Comment

                      • twinnyfo
                        Recognized Expert Moderator Specialist
                        • Nov 2011
                        • 3653

                        #12
                        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.

                        Comment

                        • CD Tom
                          Contributor
                          • Feb 2009
                          • 495

                          #13
                          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.

                          Comment

                          • twinnyfo
                            Recognized Expert Moderator Specialist
                            • Nov 2011
                            • 3653

                            #14
                            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.

                            Comment

                            • CD Tom
                              Contributor
                              • Feb 2009
                              • 495

                              #15
                              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
                              Code:
                              DoCmd.OpenForm "QBPlus"
                              following that the next code is
                              Code:
                              Private Sub Form_Open(Cancel As Integer)
                                  Dim db As Database
                                  Dim rst As Recordset
                                  Set db = CurrentDb
                                  Set rst = db.OpenRecordset("SELECT * FROM QuestionBank")
                                  If rst.EOF Then
                                      Me.Caption = "QuestionBank - Add"
                                      setEdit True
                                  End If
                                  rst.Close
                                  db.Close
                                  
                                  ignore = False
                              End Sub
                              The Questionbank is not eof, after that runs if jumps to
                              Code:
                              Private Sub Form_Current()
                                  Dim db As Database
                                  Dim rst As Recordset
                                  Dim i As Integer
                                  Dim tNode As Object
                                  Dim axCreds As TreeView
                              If ignore = False Then
                                  If IsNull(txtQuestionID) And delInProg = False Then
                                      setEdit True
                                  Else
                                      setEdit False
                                  End If
                                  If Me.Parent.Name = "ExamCreate" And IsNull(txtQuestionID) = False Then
                                      Set db = CurrentDb
                                      Set rst = db.OpenRecordset("SELECT * FROM TestQuestions WHERE [Credential Code]='" & Me.Parent.lstCred & "' AND QBNum=" & txtQuestionID)
                                      If rst.EOF Then
                                          Me.Parent.chkInc.Value = False
                                          Me.Parent.chkSeed.Enabled = False
                                          Me.Parent.chkSeed.Value = False
                                      Else
                                          Me.Parent.chkInc.Value = True
                                          Me.Parent.chkSeed.Enabled = True
                                          Me.Parent.chkSeed.Value = rst.Fields("SeedQuestion")
                                      End If
                                      rst.Close
                                      Set db = Nothing
                                  ElseIf Me.Parent.Name = "QBPlus" Then
                              'Me.Parent.Form.axCreds.Nodes
                                      If Me.Parent.axCreds.Nodes.count > 0 And Form.RecordsetClone.RecordCount > 0 Then
                                          For i = 1 To Me.Parent.axCreds.Nodes.count
                                              If InStr(Me.Parent.axCreds.Nodes(i).key, "-") Then
                                                  Me.Parent.axCreds.Nodes(i).Image = "blank"
                                              Else
                                                  Me.Parent.axCreds.Nodes(i).Image = "file"
                                              End If
                                          Next
                                          For i = 1 To Me.Parent.axBooks.Nodes.count
                                              If InStr(Me.Parent.axBooks.Nodes(i).key, "-") Then
                                                  Me.Parent.axBooks.Nodes(i).Image = "blank"
                                              Else
                                                  Me.Parent.axBooks.Nodes(i).Image = "file"
                                              End If
                                          Next
                                          
                                          If IsNull(txtQuestionID) Then Exit Sub
                                          
                                          Set db = CurrentDb
                                          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]")
                                          If rst.EOF = False Then
                                              rst.MoveFirst
                                              Do
                                                  If rst.Fields("Status") <> 0 Then
                                                      Me.Parent.axCreds.Nodes("" & rst.Fields("Credential Code") & "").Image = "used"
                                                      Me.Parent.axCreds.Nodes("" & rst.Fields("Credential Code") & "-" & cmbConcern & "").Image = "used"
                                                  Else
                                                      Me.Parent.axBooks.Nodes("" & rst.Fields("Credential Code") & "").Image = "used"
                                                      Me.Parent.axBooks.Nodes("" & rst.Fields("Credential Code") & "-" & cmbConcern & "").Image = "used"
                                                  End If
                                                  rst.MoveNext
                                              Loop Until rst.EOF
                                          End If
                                          rst.Close
                                          Set db = Nothing
                                          
                                          Set tNode = Me.Parent.axCreds.Object.SelectedItem
                                          If Not tNode Is Nothing Then
                                              If tNode.Image = "used" Then
                                                  Me.Parent.cmdAdd.Enabled = False
                                                  Me.Parent.cmdDel.Enabled = True
                                              Else
                                                  Me.Parent.cmdAdd.Enabled = True
                                                  Me.Parent.cmdDel.Enabled = False
                                              End If
                                          Else
                                              Set tNode = Me.Parent.axBooks.Object.SelectedItem
                                              If Not tNode Is Nothing Then
                                                  If tNode.Image = "used" Then
                                                      Me.Parent.cmdAdd.Enabled = False
                                                      Me.Parent.cmdDel.Enabled = True
                                                  Else
                                                      Me.Parent.cmdAdd.Enabled = True
                                                      Me.Parent.cmdDel.Enabled = False
                                                  End If
                                              End If
                                          End If
                                          Set tNode = Nothing
                                      End If
                                  End If
                              End If
                                  
                              End Sub
                              The code line setEdit false runs code
                              Code:
                              Public Sub setEdit(trigger As Boolean)
                                  txtAnswer.Locked = Not trigger
                                  txtQuestionStr.Locked = Not trigger
                                  txtQuestionStr.SetFocus
                                  subQuestionChoices.Locked = Not trigger
                                  cmbTest.Locked = Not trigger
                                  cmbConcern.Locked = Not trigger
                                  cmdConcernAdd.Visible = trigger
                                  If Me.Parent.Name <> "ExamCreate" Then
                                      cmdAdd.Visible = Not trigger
                                      lblAdd.Visible = Not trigger
                                      cmdUpd.Visible = Not trigger
                                      lblUpd.Visible = Not trigger
                                      cmdDel.Visible = Not trigger
                                      lblDel.Visible = Not trigger
                                      cmdPic.Visible = trigger
                                      lblPic.Visible = trigger
                                  Else
                                      Me.Parent.cmdAdd.Visible = Not trigger
                                      Me.Parent.lblAdd.Visible = Not trigger
                                      Me.Parent.cmdUpd.Visible = Not trigger
                                      Me.Parent.lblUpd.Visible = Not trigger
                                      Me.Parent.cmdExch.Visible = Not trigger
                                      Me.Parent.lblExch.Visible = Not trigger
                                      cmdPic.Visible = trigger
                                      lblPic.Visible = trigger
                                      Me.Parent.subQB.Locked = Not trigger
                                  End If
                                  cmdConfirm.Visible = trigger
                                  If trigger Then
                                      If IsNull(txtQuestionID) Then
                                          cmdCancel.Visible = True
                                      Else
                                          cmdCancel.Visible = False
                                      End If
                                  Else
                                      cmdCancel.Visible = False
                                  End If
                              End Sub
                              and then we hit the axCreds and get the error.
                              I don't know if this helps or not.

                              Comment

                              Working...