Populating a combo box from and XML file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a combo box that I am currently populating with a value list. I would
like to make it so that instead, the combo box would pull its values from and
XML file so that the data will be dynamically updated as the XML file is
updated. I can't find a way to use the XML file as the Control Source. Any
help would be greatly appreciated!

Carolanne
 
hi
you can't set set the control source direct. you would
have to import the xml file. this can be automated with a
macro.
 
Given an XML file in the ADO persist format (the XML you get when you save
an ADO recordset using the adPersistXML option) the following seems to work.
Note, however, that I have not used this in a 'real world' application, I
have only tested it very briefly. There may be issues or limitations of
which I am not aware.

Option Compare Database
Option Explicit

Private mrst As ADODB.Recordset

Private Sub Form_Close()

If Not mrst Is Nothing Then
If Not mrst.State = adStateClosed Then
mrst.Close
End If
End If

End Sub

Private Sub Form_Open(Cancel As Integer)

Set mrst = New ADODB.Recordset
mrst.Open CurrentProject.Path & "\test.XML"
Set mrst.ActiveConnection = Nothing
Set Me.Combo0.Recordset = mrst

End Sub

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Back
Top