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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I'm stumped

Status
Not open for further replies.
Mar 15, 2002
82
US
Hi,
To start, I'm pretty much a newbie to VB. This is a basic program which just prints predefined web pages, which we print daily for our CEO. There are 2 forms: Weather and Locations. The weather portion works fine. I'm having trouble with the Locations part of the program. I use a tree view which reads an xml file. However, I've been getting errors when I click on the tree to get more detail or when I try to add a location and I can't figure out why. If anyone can help me out, it would be appreciated. The following link has a copy of my app in a zipped file.


Thanks,
Goodfela
 
try this on your populateLocationDetails sub:


Private Sub populateLocationsDetails(objSelNode As Node)

Dim objList As IXMLDOMNodeList
Dim objLocationsElement As IXMLDOMElement
Dim objChildElement As IXMLDOMElement
Dim i As Integer

If objSelNode Is Nothing Then Exit Sub


'On Error Resume Next
If Trim(objSelNode.Tag) <> &quot;&quot; Then
Set objList = m_objDOMLocations.getElementsByTagName(&quot;WeatherLoc&quot;)

For i = 0 To objList.length - 1
If objList(i).Attributes(0).nodeValue = objSelNode.Tag Then
Set objLocationsElement = objList(i)
Exit For
End If
Next

lblElement.Caption = objLocationsElement.nodeName & &quot;: LOCID = &quot; & _
objLocationsElement.Attributes(0).nodeValue

For Each objChildElement In objLocationsElement.childNodes

If objChildElement.nodeType = NODE_ELEMENT Then
Select Case UCase(objChildElement.nodeName)
Case &quot;LOCATION&quot;
txtLocation.Text = objChildElement.nodeTypedValue
Case &quot;WEATHERURL&quot;
txtURL.Text = objChildElement.nodeTypedValue
Case &quot;PRINTCOPIES&quot;
txtCopies.Text = objChildElement.nodeTypedValue
Case &quot;PRINTING&quot;
cmbPrint.Text = objChildElement.nodeTypedValue
End Select
End If
Next objChildElement
End If

Set objChildElement = Nothing
Set objLocationsElement = Nothing
End Sub
 
Alfred,
Thanks for taking a look. However, I am still getting the same error, except now it errors out on part of the loop you added. The error is:
Run-Time error '91':
Object variable or With block variable not set

I get the error on the objList.Length part of your for statement. I was getting it on the objLocationsElement.nodeName part of the statement below your For-Next loop b/c it sets objLocationsElement to nothing in the
Set objLocationsElement = m_objDOMLocations.nodeFromID(objSelNode.Tag) statement.

Thanks for your help.
 
I figured out what I was doing wrong. Being as inexperienced as I am, I didn't realize that I needed to create a dtd file for the xml file. I created that and it works fine. I also had different field names in the select case section which alfred kindly pointed out. I used bits from an example and forgot to change that after cutting and pasting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top