Field names as variables

RcNorth

New member
Local time
Today, 09:42
Joined
Jan 19, 2009
Messages
4
I am trying to import and XML file into an existing Access table. The table has around 60+ fields, and the XML node name is equal to the field name. What I want to do is write a generic routine that will use the node name as the field name so that I don't need to deal with each field individually.

here is the code. The problem is in the ELSE of the CASE statement

Code:
Private Sub ProcessPatientNodes(ByVal inNodeList As IXMLDOMNodeList)
Dim objNode As IXMLDOMNode
Dim strNodeName As String
    
    rstPatient.AddNew
    For Each objNode In inNodeList
        strNodeName = UCase(objNode.NodeName)
        Select Case strNodeName
            Case Is = "ID"
                'ID is an auto incremented field so do not use the value in the XML file
            Case Is = "DATEOFBIRTH"
                rstPatient("DateofBirth") = ISODate(objNode.Text, "D")
            Case Else
                'Process a standard String field
                rstPatient(strNodeName) = objNode.Text
        End Select
    Next objNode
    rstPatient.Update
End Sub
 
Actually I guess my code works. There was a problem with the tables and after I did a compact and repair things are being added to the table now.
 

Users who are viewing this thread

Back
Top Bottom