vba - How to generate an XML file, base on a table in Access, every 1500 records of that table? -


i have function working export xml. wanted generate file every 1500 records of table stock_exe. tried while (not .eof) counter lost. know best way this?

first version:

public function function_xml_test()      dim rs              adodb.recordset     dim cn              adodb.connection     dim myxml           msxml2.domdocument     dim myxslt          msxml2.domdocument     dim ssql            string     dim countstring     string     dim lcounter        integer     dim icount          integer      set myxml = new msxml2.domdocument     myxml.async = false     myxml.preservewhitespace = false      set myxslt = new msxml2.domdocument     myxslt.async = false     myxslt.preservewhitespace = false      set cn = currentproject.connection     set rs = new adodb.recordset      ssql = "select * stock_exe"      countstring = "select count(*) stock_exe"      icount = currentdb.openrecordset(countstring).fields(0).value      rs.open ssql, cn      icount = rs.recordcount 'determine number of returned records      rs                  lcounter = 0 icount step 1500                myxslt.load "c:\users\stock_exe.xslt"             rs.save myxml, adpersistxml              call myxml.transformnodetoobject(myxslt.documentelement, myxml)              if isnull(forms!menuinicial!productstatus.value) or _                 isnull(forms!menuinicial!lpnfacilitystatus.value) or _                 isnull(forms!menuinicial!initialaisle.value) or _                 isnull(forms!menuinicial!finalaisle.value)                 msgbox ("as lovs!")             else                 msgbox ("criado xml!")                 myxml.save "c:\users\" & lcounter & "_" & _                              forms!menuinicial!lpnfacilitystatus.value & "_" & _                              forms!menuinicial!initialaisle.value & "_" & _                              forms!menuinicial!finalaisle.value & "_dtim_" & _                             format(now(), "ddmmyyyy_hhmm") & ".xml"             end if          next lcounter      end      rs.close     cn.close  end function 

i think i'm close, gives me following error @ point:

rs.openssql, cn 

"no value given 1 or more required parameters"

second version:

public function function_xml_test_v1()      dim rs              adodb.recordset     dim cn              adodb.connection     dim myxml           msxml2.domdocument     dim myxslt          msxml2.domdocument     dim ssql            string     dim countstring     string     dim lcounter        integer     dim icount          integer      set myxml = new msxml2.domdocument     myxml.async = false     myxml.preservewhitespace = false      set myxslt = new msxml2.domdocument     myxslt.async = false     myxslt.preservewhitespace = false      set cn = currentproject.connection     set rs = new adodb.recordset      countstring = "select count(*) stock_exe_id"      icount = currentdb.openrecordset(countstring).fields(0).value      msgbox ("icount = " & icount)      rs          lcounter = 1 icount step 1500              msgbox ("lcounter = " & lcounter)              ssql = "select * stock_exe_id" _                     & " stock_exe_id.id between lcounter , (lcounter + 1500)"              rs.open ssql, cn              myxslt.load "c:\path\to\xslt\stock_exe.xslt"             rs.save myxml, adpersistxml              call myxml.transformnodetoobject(myxslt.documentelement, myxml)              myxml.save "c:\path\to\output\" & lcounter & "_dtim_" & _                         format(now(), "ddmmyyyy_hhmm") & ".xml"              rs.close             cn.close          next lcounter      end      msgbox ("passou!")  end function 

consider domain aggregate, dcount, in loop range , sql correlated count subquery using table's autonumber field assumed exist in table field, id:

myxslt.load "c:\path\to\xslt\stock_exe.xslt"   ' moved outside loop  lcounter = 1 dcount("*", "stock_exe") step 1500        msgbox ("lcounter = " & lcounter)        ' sql correlated count subquery in clause serving row number       ssql = "select t.* stock_exe t" _                & " (select count(*) stock_exe sub sub.id <= t.id)" _                & " between " & lcounter & " , " & lcounter + 1499           rs.open ssql, cn        ' output raw xml       rs.save myxml, adpersistxml        ' run xslt (no call or .documentelement needed)       myxml.transformnodetoobject myxslt, myxml        ' save output file       myxml.save "c:\path\to\output\" & lcounter & "_dtim_" & _                   format(now(), "ddmmyyyy_hhmm") & ".xml"           rs.close  next lcounter   cn.close  ' clear resources set rs = nothing: set cn = nothing set myxml = nothing: set myxslt = nothing 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -