Originally Posted by
broecher
Occurance, yourFunctionResult{the char position}, TextIWant
1, 155, Date
2, 180, Time
3, 230, Longitude
.....
The Mid Function would be in the TextIWant field
you can't do that sir. queries only run horizontally, and on data already in the source. they cannot create new records dynamically like that. if that's what you want, create a table with 1 field: make it a long type. use a recordset in my function and add new records for as many occurrances as you find. something like this:[code]
Code:
Option Compare Database
Function EInstr()
dim rs as dao.recordset
set rs=currentdb.openrecordset("newtable")
On Error GoTo Cleanup
'******************************************************************************
' *
'Author: Adam Evanovich *
'Date: 9/17/2010 *
'Purpose: To count the number of occurances of one string inside of another. *
' *
'Arguments: *
'strBase > String in which to search for substrings *
'strSearch > Substring for which to count occurances *
' *
'******************************************************************************
Dim oCount As Long
Dim CurPos As Long
Dim lReached As Boolean
Dim strSearchPos As Long
lReached = False
CurPos = 1
Do Until lReached = True
strSearchPos = InStr(CurPos, strBase, strSearch)
If strSearchPos = 0 Then
lReached = True
else
rs.addnew
rs!NameTagValue = mid(strBase, strSearchPos + 6, _
instr(strSearchPos + 6, strBase, "</Name>"))
rs.update
end if
Loop
Cleanup:
oCount = 0
CurPos = 0
strSearchPos = 0
End Function
where strBase = the entire XML code and strSearch = "<Name>".
make sense?