Ok my turn for a problem (VB)  | | |
March 14th, 2002, 08:05 PM
|
#1 (permalink)
| | Not Really a Member
Join Date: Oct 2001
Posts: 25,400
| Ok my turn for a problem (VB)
Ok I've been bashing my head into this monitor for a few days on this one
This is going to be confusing as hell lol
Ok what I'm doing is creating a custom outlook 2000 form that populates some of the data on the form from an XML document in a public folder.. that part is not the problem. I am now "simply" having a problem retrieving some of the data from the XML file.
Ok here is a summary of some of the code and the XML I'm using.... Code: Function GetAgencyInfo() 'Routine to read the time card info into the XML Doc object
Dim strXML
GetAgencyInfo = False 'Set the return value to false, indicating the info was not read
'Get the XML body of the time card information item. Notify the user if can't find it.
'Load the XML body into strXML
strXML = ""
strXML = Application.GetNameSpace("MAPI").Folders("Public Folders").Folders("All Public Folders").Folders("ParentFolderName").Folders("SubFolderName").Folders("EvenMoreSubFolderName").Folders("AnotherSubFolder").Items("Message Title").Body
If strXML = "" Then
MsgBox "Can't find " & "Message Title" & "--the item that holds the time card data"
Exit Function
End If
Set g_xmlDoc = CreateObject("Microsoft.XMLDOM")
g_xmlDoc.async = "false"
g_xmlDoc.loadXML (strXML)
GetAgencyInfo = True 'Set the return value to true, indicating that the XML is in g_xmlDoc
End Function
Sub PopulateAgencies() 'Routine to populate the customer list with customers
'that have tasks to which the user can charge
Dim objAgencyNodes, objAgencyNode
g_objControls("cmbOrganization").Clear 'Clear the Customer List
Set objAgencyNodes = g_xmlDoc.getElementsByTagName("TLAgency")
For Each objAgencyNode In objAgencyNodes
g_objControls("cmbOrganization").AddItem (objAgencyNode.getElementsByTagName("Name").Item(0).Text)
Next
g_blnFormIsLoading = False ' Now we want to allow the user events for UserDept and UserOrg to be fired
Set g_objSelCustNode = GetAgencyNode(Item.UserProperties("UserOrg"))
If g_objSelCustNode Is Nothing Then
MsgBox "Ah g_objSelCustNode = nothing"
Else
MsgBox "g_objSelCustNode = something, good!"
End If
Set objAgencyNodes = Nothing
Set objAgencyNode = Nothing
End Sub
Sub PopulateOffices()
Dim objOffices
Dim objOffice
Set objOffices = Nothing
Set objOffice = Nothing
g_objControls("cmbOfficeSymbol").Clear
g_objControls("cmbOfficeSymbol") = ""
Set objOffices = g_objSelCustNode.selectNodes("OfficeSymbol")
If objOffices Is Nothing Then
MsgBox "No Data For ObjOffices"
Exit Sub
End If
MsgBox "objOffices = " & objOffices.Length
'Populate the task list with only those tasks to which the user can charge
For Each objOffice In objOffices 'For each Office
g_objControls("cmbOfficeSymbol").AddItem (objOffice.getElementsByTagName("Name").Item(0).Text)
MsgBox "For each objoffice in objoffices next box should be a task name"
MsgBox objOffice.getElementsByTagName("Name").Item(0).Text & " Task Name"
Next
Set objOffices = Nothing
Set objOffice = Nothing
End Sub
Function GetAgencyNode(strAgencyName)
Dim objAgencyNodes
Dim objAgency
' ''' On Error Resume Next
Set GetAgencyNode = Nothing 'Initialize the customer node to nothing
Set objAgencyNodes = g_xmlDoc.getElementsByTagName("TLAgency")
''' Set objAgencyNodes = g_xmlDoc.selectSingleNode("TLAgency")
For Each objAgency In objAgencyNodes
If objAgency.getElementsByTagName("Name").Item(0).Text = strAgencyName Then
MsgBox "GetAgencyNode=" & objAgency.getElementsByTagName("Name").Item(0).Text
Set GetAgencyNode = objAgency 'Set the return value
Exit For
End If
Next
Set objAgencyNodes = Nothing
Set objAgency = Nothing
End Function
anything starting with g_ is global so you won't see it declared here
now for the XML Code: <?xml version="1.0" ?>
<UCRAgencyInfo>
<TLAgencies>
<TLAgency>
<Name>Group 1</Name>
<Description>Full Description of Group 1</Description>
<OfficeSymbol>
<Name>OS 1</Name>
<Name>OS 2</Name>
<Name>OS 3</Name>
</OfficeSymbol>
</TLAgency>
<TLAgency>
<Name>Group 2</Name>
<Description>Full Description of Group 2</Description>
<OfficeSymbol>
<Name>Ummmm stuff</Name>
<Name>2nd bit of stuff</Name>
<Name>3rd bit of stuff</Name>
</OfficeSymbol>
</TLAgency>
</TLAgencies>
</UCRAgencyInfo>
The problem...
I can get it to put Group 1, and Group 2 into a drop down box no problem.. now what is supposed to happen is it will populate a 2nd drop down box with the office symbols pertaining to THAT group.
For instance if I select Group 1 then OS 1, OS 2, OS 3 should show up in teh 2nd drop down box...
however, only OS 1 shows up
I can't for the life of me get the rest of that freakin' data LOL
I don't like the structure of it much, but I basically got a lot of this from another prog one of the other guys wrong, and applied to my case... however I haven't done a very good job of it lol
Any ideas?
Last edited by vass0922 : March 14th, 2002 at 08:13 PM.
|
| |
March 14th, 2002, 08:34 PM
|
#2 (permalink)
| | Ordained Mommy
Join Date: Oct 2001 Location: Big Sky Country
Posts: 4,259
|  Whoa vass and I thought I was gonna see a "lifes" problem!
Wish I can help out with that one! Sorry
Can't wait to see the results of the answer tho.
NeoStar |
| |
March 14th, 2002, 09:07 PM
|
#3 (permalink)
| | Senior Member
Join Date: Oct 2001 Location: Orange,CA
Posts: 782
|
*bump for vass* since he was soo kind to write that thing up for me,even though i think it wont work  |
| |
March 14th, 2002, 09:21 PM
|
#4 (permalink)
| | Banned
Join Date: Oct 2001
Posts: 447
|
let's see, you want the choice of a dropdown to filter (or populate) another dropdown...
So when I choose an agency, then office dropdown only shows offices for that agency, right???
Piece o' cake in PB, oops this is VB.
My guess is your parsing your XML improperly, where as you need to store data and display dependent upon choice... |
| |
March 14th, 2002, 09:31 PM
|
#5 (permalink)
| | Not Really a Member
Join Date: Oct 2001
Posts: 25,400
|
Correct, I simply don't know which objects/methods fit into the puzzle correctly
I'm not real familiar with the API unfortunately... I've figured out a lot...
Ok my take on things...
One of a few things...
MsgBox "objOffices = " & objOffices.Length
Returns 1, instead of 3 which it should be...
GetAgencyNode()
Using the wrong method to get the node...
Set objAgencyNodes = g_xmlDoc.getElementsByTagName("TLAgency")
or a better way to do this...
g_objControls("cmbOfficeSymbol").AddItem (objOffice.getElementsByTagName("Name").Item(0).Te xt)
__________________
Helicopters don't fly; they vibrate so much and make so much noise that the earth rejects them.
|
| |
March 14th, 2002, 11:07 PM
|
#6 (permalink)
| | Member
Join Date: Oct 2001 Location: NJ
Posts: 321
|
I didn't read the whole code (it's late & i've got a headache), but one line says:
g_xmlDoc.async = "false"
Is that right? I mean the use of the "" with a boolean type? Shouldn't it just be:
g_xmlDoc.async = False |
| |
March 14th, 2002, 11:09 PM
|
#7 (permalink)
| | Not Really a Member
Join Date: Oct 2001
Posts: 25,400
|
yeah typically... like I said I didn't write that part.. Don't think it'll make that much of a difference but I will give it a shot
didn't really pay attention to it LOL |
| |
March 14th, 2002, 11:12 PM
|
#8 (permalink)
| | Not Really a Member
Join Date: Oct 2001
Posts: 25,400
|
Last edited by vass0922 : March 14th, 2002 at 11:33 PM.
|
| |
March 26th, 2002, 12:38 AM
|
#9 (permalink)
| | Member
Join Date: Oct 2001 Location: Austin, Texas
Posts: 39
|
WOW!!! Interesting
try this:
Set one_objOffices = g_objSelCustNode.selectNodes("OfficeSymbol")
Set objOffices = one_objOffices .getElementsByTagName("Name")
if this looks something stupid, just ignore me... LOL
this is my first time looking at VB
i usually prog in C |
| |
March 27th, 2002, 04:27 PM
|
#10 (permalink)
| | ph34r t3h g04t
Join Date: Oct 2001 Location: Kingsford, MI
Posts: 19,573
|
Vass - You get an answer to this yet??? A colleague of mine suggested reading the XML file as a database using ADO. This way, you can use standard filter methods with the controls. I am not 100% clear on exactly how he meant to use it, but it equates to setting the XML files as the database and then the tags as recordsets. You can declare deeper tags as they're own recordsets and declare the upper ones as primary keys through code and have the filters sort that way? Follow? I understand how he got his to work sort of, but explaining it is like trying to teach myself how to speak. :P
-Whir |
| | | Thread Tools | Search this Thread | | | | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | | | Most Active Discussions | | | | | Recent Discussions  | | | | | |