Hi All,
Creating a scheduled agent to dynamically create subforms pertaining to specific locations that offices reside in. The form opened by the user will encompass a pertiaining subform created that will have items listed in a table along with fields for the user to provide a count of the items. I am building the subforms on a scheduled basis for use and have achieved this design other than the fact the table row creation halts when being appended to the created subform. For example if a location has 300 items in the items view, the agent acknowledges all 300 documents to get the item name from, shows the table row data as expected for the exporter, the DXL importer log completes with no error. However when i open the subforms, there will be a less amount of table rows found then the subforms were created.
I have appended a snippet of my code for review:
'See if we already an item list subform and get rid of it
Set subForm=db.GetForm("itemlist-" + configStore)
If Not (subForm Is Nothing) Then
Call subForm.Remove()
End If
Set nc = db.CreateNoteCollection(False)
nc.SelectSubForms = True
nc.SelectionFormula = |$Title="itemtemplate"|
Call nc.BuildCollection
Set exporter = session.CreateDXLExporter()
dxlcode=exporter.Export(nc)
Dim bstart As Long, bend As Long, blen As Long
bstart=Instr(dxlcode, "<body>")
bend=Instr(dxlcode, "</body>")
blen=Len(dxlcode)
'Msgbox Cstr(dxlcode)
'Exit Sub
y=1
newbody=Replace(Left(dxlcode, (bstart+5)), "itemtemplate", "itemlist-" + configStore)
newbody=newbody + GetBodyTop()
'loop thru the items view and add allowable items for latest 10key entry subform
Set item_doc=item_view.GetFirstDocument
While Not item_doc Is Nothing
findex=Cstr(y)
If (y<10) Then
findex="0" + findex
End If
'add for dxl import
item_namn=Trim(Cstr(item_doc.itemName(0)))
'replace &'s with '&'
amp_poz=Instr(1,Cstr(item_doc.itemName(0)),"&",5)
If amp_poz <> 0 Then
part1=Strleft(Cstr(item_doc.itemName(0)),"&")
part2=Strright(Cstr(item_doc.itemName(0)), "&")
item_namn=Trim(part1+"&"+part2)
’ Msgbox item_namn
End If
…
'%%% add table row to table
newbody=newbody + GetTableRow(item_namn+" -#"+Cstr(item_doc.itemNumber(0)), findex)
y=y+1
Set item_doc=item_view.GetNextDocument(item_doc)
Wend
tnxt:
newbody=newbody + GetBodyBottom()
newbody=newbody + Right(dxlcode, (blen-bend+1))
fileNum% = Freefile()
fileName$ = "data.xml"
’ Write out some employee data.
Open fileName$ For Output As fileNum%
Write #fileNum%, newbody
Close fileNum%
On Error Goto errh
Set importer=session.CreateDXLImporter(newbody, db)
importer.ExitOnFirstFatalError=True
importer.ReplaceDBProperties = False
importer.ReplicaRequiredForReplaceOrUpdate = False
importer.ACLImportOption = DXLIMPORTOPTION_REPLACE_ELSE_IGNORE
importer.DesignImportOption = DXLIMPORTOPTION_CREATE
Call importer.Process
…
'%%%% TO BUILD TOP OF EXPORT ENTRY
Function GetBodyTop() As String
Dim restxt As String
restxt=|<richtext>
<table minrowheight='0.3000in' widthtype='fixedcenter' rowspacing='0.0097in'
refwidth=‘4.1222in’>|
GetBodyTop=restxt
End Function
…
'%%%% TO ADD ROWS TO TABLE
Function GetTableRow(fieldTitle As String, fieldIndex As String) As String
Dim restxt As String
restxt={<tablerow>
<font size=‘8pt’ style=‘bold’ name=‘Arial’
pitch=‘variable’ truetype=‘true’ familyid=‘20’/>} + fieldTitle + {<font size=‘8pt’ style=‘bold’
name=‘Arial’ pitch=‘variable’ truetype=‘true’ familyid=‘20’/>:
<font size=‘8pt’ name=‘Arial’ pitch=‘variable’
truetype=‘true’ familyid=‘20’/><field usenotesstyle=‘false’ height=‘0.2500in’ width=‘1in’ multiline=‘true’ borderstyle=‘single’ type=‘number’ kind=‘editable’
name=‘invItem} + fieldIndex + {’><numberformat format=‘fixed’ digits=‘2’ punctuated=‘true’
parens=‘false’ percent=‘false’/>@If(@IsNumber( @ThisValue ); @ThisValue; 0)<font size=‘8pt’ name=‘Arial’
pitch=‘variable’ truetype=‘true’ familyid=‘20’/>
}
GetTableRow=restxt
End Function
…
'%%%% FUNCTION TO CLOSE THE EXPORT ENTRY
Function GetBodyBottom() As String
Dim restxt As String
restxt=|</table>
|
GetBodyBottom=restxt
End Function
Basically a location with 300 items will script a subform of only 50 table rows with no error msg found whereas the test dxl file created shows all entries.
Any direction to resolution or to troubleshoot this further would be greatly appreciated.
TIA,
Geoff-