Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error calling function from another function

Status
Not open for further replies.
Apr 28, 2006
69
NL
Hi all . I have an application that i try to call Command7_Click() from with in Command5_Click function but when i do so i get the following error:


error:
Code:
Run-time error 91 object variable or with block variable not set
If i click on a button manually to activate Command7_Click() the function inserts data to mysql without any error. Could any one tell me how to fix this error.Thanks



damerror.jpg




Code:
Private [B]Sub Command5_Click()[/B]
Select Case Index
    Case 0:
        If Text3.Text <> "" Then
            Text4.Text = Inet1.OpenURL(Text3.Text, icString)
        End If
    
    Case 1:
        End
End Select
[B]Command7_Click[/B]
End Sub

Private Sub Command7_Click()
 Dim CNN As ADODB.Connection
Set CNN = New ADODB.Connection
CNN.Open "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=visualbasic67;USER=root;PASSWORD=;OPTION=3;"


 Dim Parser As New clsXMLParser
  Dim Node As clsXMLNode
  Dim Child As clsXMLNode
  Dim fn As Long
  Dim i As Long
   Dim path As String
  Dim title As String

  fn = FreeFile
  Open "C:\temp.dat" For Output As #fn
    Print #fn, Text4.Text
  Close #fn

  Call Parser.Parse("C:\temp.dat")
  Call Kill("C:\temp.dat")
  
  Set Node = Parser.ParentNode
   
   For i = 1 To Node.ChildrenCount
      Set Child = Node.enumChild(i)
      If LCase$(Child.Name) = "song" Then
        path = Child.getAttribute("path")
        title = Child.getAttribute("title")
   
[COLOR=red]CNN.Execute "INSERT INTO songstest (filename,title,artist,album,LastModified) VALUES('" & path & "','" & title & "','" & Trim(ListView1.ListItems(ListView1.SelectedItem.Index).SubItems(2)) & "','" & Trim(ListView1.ListItems(ListView1.SelectedItem.Index).SubItems(3)) & "' , '" & List3.Text & "')"
        [/color]  ===> error pointing at 

       
      End If
   Next
 CNN.Close

MsgBox " successfull"
End Sub
 
When it stops on that phrase, try running

?ListView1.SelectedItem.Index

in the immedaite window
 
try adding
Code:
if ListView1.SelectedItem is Nothing then
msgbox "Nothing Selected"
end if


and try again


Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
I tried it and got this pop up massagebox and displayiing this :

Compile error:

End if without block if

ok help

and pointing in yellow to the same insert statment!!
 
>I tired it and same error again!!

Now think very carefully what this might mean
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top