home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

Ok my turn for a problem (VB)

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 1778
Discussions: 200,990, Posts: 2,379,885, Members: 246,359
Old March 14th, 2002, 08:05 PM   Digg it!   #1 (permalink)
Not Really a Member
 
Join Date: Oct 2001
Posts: 25,400
Red face
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.
vass0922 is online now   Reply With Quote
Old March 14th, 2002, 08:34 PM     #2 (permalink)
Ordained Mommy
 
NeoStarO1's Avatar
 
Join Date: Oct 2001
Location: Big Sky Country
Posts: 4,259
Blog Entries: 1
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
NeoStarO1 is offline   Reply With Quote
Old March 14th, 2002, 09:07 PM     #3 (permalink)
Senior Member
 
Pshawn5's Avatar
 
Join Date: Oct 2001
Location: Orange,CA
Posts: 782
Send a message via ICQ to Pshawn5 Send a message via AIM to Pshawn5 Send a message via MSN to Pshawn5 Send a message via Yahoo to Pshawn5
*bump for vass* since he was soo kind to write that thing up for me,even though i think it wont work
Pshawn5 is offline   Reply With Quote
Old March 14th, 2002, 09:21 PM     #4 (permalink)
Banned
 
qball's Avatar
 
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...
qball is offline   Reply With Quote
Old 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.
vass0922 is online now   Reply With Quote
Old 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
Mr. NoOne is offline   Reply With Quote
Old 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
vass0922 is online now   Reply With Quote
Old March 14th, 2002, 11:12 PM     #8 (permalink)
Not Really a Member
 
Join Date: Oct 2001
Posts: 25,400
I changed it, same result... *sigh*
Don't make me go to another forum
lol

posted on another forum... see what happens..

http://www.vbxml.com/messageboards/m...=vbxmlprog3788
(site sucks in opera!! arghhh)

Last edited by vass0922 : March 14th, 2002 at 11:33 PM.
vass0922 is online now   Reply With Quote
Old 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
kakyoin is offline   Reply With Quote
Old March 27th, 2002, 04:27 PM     #10 (permalink)
ph34r t3h g04t
 
Whir's Avatar
 
Join Date: Oct 2001
Location: Kingsford, MI
Posts: 19,573
Blog Entries: 7
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
Whir is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (3075)
Charges against non-tippers dropped.. (20)
Health Care Rationing (12)
Delete an OS (17)
Nvidia GTX 260 problem (10)
Laptop with wireless problem. (12)
windows vista security holes (19)
Wireless Televisions. (12)
CPU fan stops spinning randomly (11)
Regular Build (11)
Point and Shoot Camera Suggestions. (8)
windows 7 problem (7)
[F@H SPAM 11/16/09] ! 1/2 months to.. (39)
Internet Lost (5)
Recent Discussions
Foxconn Blackops x48 MoBo (2)
Q9650 vs. Q9550 (0)
Desktop Calendar Application (2)
Looking for new motherboard (1)
soundmon.exe (8)
Jedi Academy Problem (3)
Can a page file be "too big".. (1)
Nvidia GTX 260 problem (10)
Point and Shoot Camera Suggestions. (8)
Size after cutting 700Mb file is 2.5 .. (0)
Delete an OS (17)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (39)
windows vista security holes (19)
updating BIOS via winflash, claims fi.. (1)
New Server Configuration Suggestions (0)
cheap gaming laptop? (12)
Unallocated Space (2)
help me pls laptop just stopped worki.. (1)
C# + LINQ Help (7)
Dynex DX E-402 (3)
EVGA 9800 gtx help with finding a goo.. (12)
Multiple Restarts Required at Boot (5)
cell phone won't work (0)
Is the PSU I received dead? (15)
Can't open Word (12)


All times are GMT -4. The time now is 08:42 AM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28