<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Accounting systems &#187; Patrick Jones</title>
	<atom:link href="http://accountingsystems.ie/?feed=rss2&#038;author=2" rel="self" type="application/rss+xml" />
	<link>http://accountingsystems.ie</link>
	<description>Our free tips and tricks blog for Intact accounts, Sage, Syspro, Quickbook and bits of SAP and Oracle</description>
	<lastBuildDate>Tue, 06 Jul 2010 19:48:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Reading a SAP XML file into Access</title>
		<link>http://accountingsystems.ie/?p=30</link>
		<comments>http://accountingsystems.ie/?p=30#comments</comments>
		<pubDate>Tue, 06 Jul 2010 19:48:47 +0000</pubDate>
		<dc:creator>Patrick Jones</dc:creator>
				<category><![CDATA[SAP / Oracle]]></category>
		<category><![CDATA[Automation]]></category>
		<category><![CDATA[SAP]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://accountingsystems.ie/?p=30</guid>
		<description><![CDATA[I use a free product call chilkatxml from chilkatsoft.com, The site has loads of samples but initially I found it difficult to iteriate through the record loops in the xml file.  I have detailed the code I used to load XML orders into an access database.
The first phase is to read the file into [...]]]></description>
			<content:encoded><![CDATA[<p>I use a free product call chilkatxml from <a href="http://www.chilkatsoft.com">chilkatsoft.com</a>, The site has loads of samples but initially I found it difficult to iteriate through the record loops in the xml file.  I have detailed the code I used to load XML orders into an access database.</p>
<p>The first phase is to read the file into an array and the second phase will post that array into an access database. This is similar to theExcel to Access sample but I am using an array to store the data.</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Dim</span> xml <span style="color: #000080;">As</span> ChilkatXml
<span style="color: #000080;">Dim</span> rec1 <span style="color: #000080;">As</span> ChilkatXml, rec0 <span style="color: #000080;">As</span> ChilkatXml
<span style="color: #000080;">Dim</span> tmpLines(500, 10), i <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>, tmpCount <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span> <span style="color: #008000;">' change the array depth if needed
</span><span style="color: #000080;">Dim</span> tmpHeader(25) <span style="color: #008000;">' change to the number of headers filds you have
</span><span style="color: #000080;">Dim</span> rst <span style="color: #000080;">As</span> Recordset, rstStock <span style="color: #000080;">As</span> Recordset
<span style="color: #000080;">Dim</span> x <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>
&nbsp;
<span style="color: #008000;">' Load the input document.
</span><span style="color: #000080;">Set</span> xml = <span style="color: #000080;">New</span> ChilkatXml
xml.LoadXMLFile tmpFile <span style="color: #008000;">' tmpfile is the XML file passed to this function
</span>
<span style="color: #008000;">'Header
</span><span style="color: #000080;">Set</span> rec1 = xml.FindChild(<span style="color: #800000;">&quot;Header&quot;</span>)
    <span style="color: #000080;">If</span> (rec1.FindChild2(<span style="color: #800000;">&quot;OrderNumber&quot;</span>) = 1) <span style="color: #000080;">Then</span>
        tmpHeader(1) = rec1.Content
        rec1.GetParent2
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
    <span style="color: #000080;">If</span> (rec1.FindChild2(<span style="color: #800000;">&quot;CreationDate&quot;</span>) = 1) <span style="color: #000080;">Then</span>
        tmpHeader(2) = rec1.Content
        rec1.GetParent2
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
    <span style="color: #000080;">If</span> (rec1.FindChild2(<span style="color: #800000;">&quot;CompanyCode&quot;</span>) = 1) <span style="color: #000080;">Then</span>
        tmpHeader(3) = Right(<span style="color: #800000;">&quot;000&quot;</span> &amp; rec1.Content, 3)
        rec1.GetParent2
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
<span style="color: #008000;">'ship address
</span><span style="color: #000080;">Set</span> rec1 = xml.FindChild(<span style="color: #800000;">&quot;Partners&quot;</span>)
    <span style="color: #000080;">If</span> (rec1.FindChild2(<span style="color: #800000;">&quot;Identifier&quot;</span>) = 1) <span style="color: #000080;">Then</span>
        tmpHeader(4) = rec1.Content
        rec1.GetParent2
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
    <span style="color: #000080;">If</span> (rec1.FindChild2(<span style="color: #800000;">&quot;Name1&quot;</span>) = 1) <span style="color: #000080;">Then</span>
        tmpHeader(5) = rec1.Content
        rec1.GetParent2
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
    <span style="color: #000080;">If</span> (rec1.FindChild2(<span style="color: #800000;">&quot;Name2&quot;</span>) = 1) <span style="color: #000080;">Then</span>
        tmpHeader(6) = rec1.Content
        rec1.GetParent2
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
    <span style="color: #000080;">If</span> (rec1.FindChild2(<span style="color: #800000;">&quot;Street&quot;</span>) = 1) <span style="color: #000080;">Then</span>
        tmpHeader(7) = rec1.Content
        rec1.GetParent2
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
    <span style="color: #000080;">If</span> (rec1.FindChild2(<span style="color: #800000;">&quot;PostCode&quot;</span>) = 1) <span style="color: #000080;">Then</span>
        tmpHeader(8) = rec1.Content
        rec1.GetParent2
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
    <span style="color: #000080;">If</span> (rec1.FindChild2(<span style="color: #800000;">&quot;CountryCode&quot;</span>) = 1) <span style="color: #000080;">Then</span>
        tmpHeader(9) = rec1.Content
        rec1.GetParent2
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
    <span style="color: #000080;">If</span> (rec1.FindChild2(<span style="color: #800000;">&quot;City&quot;</span>) = 1) <span style="color: #000080;">Then</span>
        tmpHeader(10) = rec1.Content
        rec1.GetParent2
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
<span style="color: #000080;">Set</span> rec1 = xml.FindChild(<span style="color: #800000;">&quot;Items&quot;</span>)
&nbsp;
<span style="color: #000080;">If</span> (rec1.FirstChild2() = 0) <span style="color: #000080;">Then</span>
    <span style="color: #000080;">Set</span> rec1 = <span style="color: #000080;">Nothing</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
<span style="color: #000080;">Set</span> rec0 = rec1.GetParent()
&nbsp;
i = 1
<span style="color: #000080;">Do</span> <span style="color: #000080;">While</span> <span style="color: #000080;">Not</span> (rec0 <span style="color: #000080;">Is</span> <span style="color: #000080;">Nothing</span>)
&nbsp;
    <span style="color: #000080;">If</span> (rec0.FindChild2(<span style="color: #800000;">&quot;Material&quot;</span>) = 1) <span style="color: #000080;">Then</span>
        tmpLines(i, 1) = rec0.Content
        rec0.GetParent2
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
    <span style="color: #000080;">If</span> (rec0.FindChild2(<span style="color: #800000;">&quot;Description&quot;</span>) = 1) <span style="color: #000080;">Then</span>
        tmpLines(i, 2) = rec0.Content
        rec0.GetParent2
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
    <span style="color: #000080;">If</span> (rec0.FindChild2(<span style="color: #800000;">&quot;Quantity&quot;</span>) = 1) <span style="color: #000080;">Then</span>
        tmpLines(i, 3) = rec0.Content
        rec0.GetParent2
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
    <span style="color: #000080;">If</span> (rec0.FindChild2(<span style="color: #800000;">&quot;DeliveryDate&quot;</span>) = 1) <span style="color: #000080;">Then</span>
        tmpLines(i, 4) = rec0.Content
        rec0.GetParent2
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
    <span style="color: #000080;">If</span> (rec0.FindChild2(<span style="color: #800000;">&quot;PricePerUnit&quot;</span>) = 1) <span style="color: #000080;">Then</span>
        tmpLines(i, 5) = rec0.Content
        rec0.GetParent2
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
    <span style="color: #000080;">If</span> (rec0.FindChild2(<span style="color: #800000;">&quot;ItemText&quot;</span>) = 1) <span style="color: #000080;">Then</span>
        tmpLines(i, 6) = <span style="color: #800000;">&quot;&quot;</span> &amp; rec0.Content
        rec0.GetParent2
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
    <span style="color: #000080;">If</span> (rec0.FindChild2(<span style="color: #800000;">&quot;InfoRecordPOText&quot;</span>) = 1) <span style="color: #000080;">Then</span>
        tmpLines(i, 7) = <span style="color: #800000;">&quot;&quot;</span> &amp; rec0.Content
        rec0.GetParent2
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
    <span style="color: #000080;">If</span> (rec0.FindChild2(<span style="color: #800000;">&quot;MaterialPOText &quot;</span>) = 1) <span style="color: #000080;">Then</span>
        tmpLines(i, 8) = <span style="color: #800000;">&quot;&quot;</span> &amp; rec0.Content
        rec0.GetParent2
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
    <span style="color: #000080;">If</span> (rec0.FindChild2(<span style="color: #800000;">&quot;DeliveryText&quot;</span>) = 1) <span style="color: #000080;">Then</span>
        tmpLines(i, 9) = <span style="color: #800000;">&quot;&quot;</span> &amp; rec0.Content
        rec0.GetParent2
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
    <span style="color: #008000;">'now check for vendor material number
</span>    <span style="color: #000080;">If</span> (rec0.FindChild2(<span style="color: #800000;">&quot;VendorMaterialNumber&quot;</span>) = 1) <span style="color: #000080;">Then</span>
        tmpLines(i, 10) = <span style="color: #800000;">&quot;&quot;</span> &amp; rec0.Content
        rec0.GetParent2
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
    <span style="color: #008000;">' Move to the next sibling. The internal reference within node is updated
</span>    <span style="color: #008000;">' to the node's next sibling. If no siblings remain, it returns 0.
</span>    <span style="color: #000080;">If</span> (rec0.NextSibling2() = 0) <span style="color: #000080;">Then</span>
        <span style="color: #000080;">Set</span> rec0 = <span style="color: #000080;">Nothing</span>
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
    i = i + 1
&nbsp;
<span style="color: #000080;">Loop</span>
&nbsp;
<span style="color: #008000;">' now write the data into the tblImport
</span><span style="color: #000080;">Set</span> rst = CurrentDb.OpenRecordset(<span style="color: #800000;">&quot;tblImportData&quot;</span>)
&nbsp;
tmpCount = 0
x = 1
<span style="color: #000080;">Do</span> <span style="color: #000080;">While</span> Len(tmpLines(x, 2) &amp; <span style="color: #800000;">&quot;&quot;</span>) &gt; 0
    rst.AddNew
    <span style="color: #008000;">'rst!O_Number = tmpHeader(1)
</span>    rst!O_Entity = tmpHeader(3)
    rst!O_Date = DateSerial(Left(tmpHeader(2), 4), Val(Left(Right(tmpHeader(2), 4), 2)), Val(Right(tmpHeader(2), 2)))
    <span style="color: #000080;">If</span> Len(tmpLines(x, 1) &amp; <span style="color: #800000;">&quot;&quot;</span>) &gt; 0 <span style="color: #000080;">Then</span>
        rst!O_Part = tmpLines(x, 1)
    <span style="color: #000080;">Else</span>
        <span style="color: #008000;">'try the vendor material number
</span>        rst!O_Part = tmpLines(x, 10)
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
    <span style="color: #008000;">'rst!O_AltPArt = tmpLines(x, 1)
</span>    rst!O_PartOrg = tmpLines(x, 1)
    rst!O_Desc = tmpLines(x, 2)
    rst!O_Qty = tmpLines(x, 3)
    rst!O_Price = tmpLines(x, 5)
    rst!O_Price2 = tmpLines(x, 5)
    rst!O_Extended = Val(Nz(tmpLines(x, 5), 0)) * Val(Nz(tmpLines(x, 3), 0))
    rst!O_ImpDate = <span style="color: #000080;">Date</span>
    rst!O_ShipName = tmpHeader(5)
    rst!O_Ship1 = tmpHeader(6)
    rst!O_Ship2 = tmpHeader(7)
    rst!O_Ship3 = tmpHeader(8)
    rst!O_Ship4 = tmpHeader(9)
    rst!O_Ship5 = tmpHeader(10)
    <span style="color: #008000;">'rst!O_Ship6=&quot;&quot;
</span>    rst!O_Processed = 0
    rst!O_Failed = 0
    rst!O_Validated = 0
    rst!O_Disc = 0
    rst!O_Number = tmpHeader(1) &amp; <span style="color: #800000;">&quot;-&quot;</span> &amp; rst!O_Warehouse
    <span style="color: #000080;">Set</span> rstStock = <span style="color: #000080;">Nothing</span>
&nbsp;
    rst!O_PriceList = <span style="color: #800000;">&quot;A&quot;</span>
    <span style="color: #008000;">'rst!O_FailReason
</span>    <span style="color: #008000;">'rst!O_ORder
</span>    <span style="color: #008000;">'rst!O_Master
</span>    rst!O_LineShipDate = DateSerial(Left(tmpLines(x, 4), 4), Val(Left(Right(tmpLines(x, 4), 4), 2)), Val(Right(tmpLines(x, 4), 2)))
    <span style="color: #008000;">'rst!O_OrderDate
</span>    rst!O_Inactive = 0
    rst!O_Text = tmpLines(x, 6) &amp; vbCrLf &amp; tmpLines(x, 7) &amp; vbCrLf &amp; tmpLines(x, 8) &amp; vbCrLf &amp; tmpLines(x, 9) &amp; vbCrLf
    rst.Update
    tmpCount = tmpCount + 1
    x = x + 1
<span style="color: #000080;">Loop</span>
<span style="color: #000080;">If</span> tmpCount &gt; 0 <span style="color: #000080;">Then</span>
    MsgBox <span style="color: #800000;">&quot;Order Loaded&quot;</span>
<span style="color: #000080;">Else</span>
    MsgBox <span style="color: #800000;">&quot;No order lines loaded - check XML File&quot;</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://accountingsystems.ie/?feed=rss2&amp;p=30</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exporting Signed Numerics EBCDIC</title>
		<link>http://accountingsystems.ie/?p=24</link>
		<comments>http://accountingsystems.ie/?p=24#comments</comments>
		<pubDate>Sun, 06 Jun 2010 19:41:51 +0000</pubDate>
		<dc:creator>Patrick Jones</dc:creator>
				<category><![CDATA[Syspro]]></category>
		<category><![CDATA[Impact Award]]></category>
		<category><![CDATA[Legacy Systems]]></category>

		<guid isPermaLink="false">http://accountingsystems.ie/?p=24</guid>
		<description><![CDATA[I needed a function to create an EBCDIC overpunch to numeric values in an access database when exporting the data as text files for loading into OneSource.
This function might help if you need something similar

Function EbcDic(ByVal tmpNumber As Double, ByVal tmpDec As Integer, ByVal tmpPlaces As Integer)
'--------------------------------------------------------------------------------------
'OneSource Requirement for Signed Numeric Fields
'Below is the conversion [...]]]></description>
			<content:encoded><![CDATA[<p>I needed a function to create an EBCDIC overpunch to numeric values in an access database when exporting the data as text files for loading into OneSource.</p>
<p>This function might help if you need something similar</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Function</span> EbcDic(<span style="color: #000080;">ByVal</span> tmpNumber <span style="color: #000080;">As</span> <span style="color: #000080;">Double</span>, <span style="color: #000080;">ByVal</span> tmpDec <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>, <span style="color: #000080;">ByVal</span> tmpPlaces <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>)
<span style="color: #008000;">'--------------------------------------------------------------------------------------
</span><span style="color: #008000;">'OneSource Requirement for Signed Numeric Fields
</span><span style="color: #008000;">'Below is the conversion table of signed numeric values (right most over-punch character) to EBCIDIC:
</span><span style="color: #008000;">'(you do not need to worry about positive numbers, it is only negative numbers that need the translation)
</span>
<span style="color: #008000;">'Positive   'Negative
</span><span style="color: #008000;">'0 = {      '0 = }
</span><span style="color: #008000;">'1 = A      '1 = J
</span><span style="color: #008000;">'2 = B      '2 = K
</span><span style="color: #008000;">'3 = C      '3 = L
</span><span style="color: #008000;">'4 = D      '4 = M
</span><span style="color: #008000;">'5 = E      '5 = N
</span><span style="color: #008000;">'6 = F      '6 = O
</span><span style="color: #008000;">'7 = G      '7 = P
</span><span style="color: #008000;">'8 = H      '8 = Q
</span><span style="color: #008000;">'9 = I      '9 = R
</span><span style="color: #008000;">'
</span><span style="color: #008000;">'  (for example a -592.52 ... will be passed as 00000005925K)
</span><span style="color: #008000;">'--------------------------------------------------------------------------------------
</span>
<span style="color: #000080;">Dim</span> tmpStr, tmpTrans, tmpPos, tmpFactor
<span style="color: #000080;">Dim</span> tmpFilled
tmpFilled = <span style="color: #800000;">&quot;00000000000000&quot;</span>
&nbsp;
<span style="color: #000080;">If</span> Len(tmpNumber &amp; <span style="color: #800000;">&quot;&quot;</span>) = 0 <span style="color: #000080;">Then</span>
    EbcDic = right(tmpFilled, tmpPlaces)
    <span style="color: #000080;">Exit</span> <span style="color: #000080;">Function</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
<span style="color: #000080;">Select</span> <span style="color: #000080;">Case</span> tmpDec
<span style="color: #000080;">Case</span> 0
    tmpFactor = 1
<span style="color: #000080;">Case</span> 1
    tmpFactor = 10
<span style="color: #000080;">Case</span> 2
    tmpFactor = 100
<span style="color: #000080;">Case</span> 3
    tmpFactor = 1000
<span style="color: #000080;">Case</span> 4
    tmpFactor = 10000
<span style="color: #000080;">End</span> <span style="color: #000080;">Select</span>
&nbsp;
<span style="color: #000080;">If</span> tmpNumber &gt;= 0 <span style="color: #000080;">Then</span>
    EbcDic = right(tmpFilled &amp; Int(tmpNumber * tmpFactor), tmpPlaces)
    <span style="color: #000080;">Exit</span> <span style="color: #000080;">Function</span>
<span style="color: #000080;">Else</span>
    tmpTrans = Int((tmpNumber * tmpFactor) * -1)
    tmpPos = InStr(1, <span style="color: #800000;">&quot;0123456789&quot;</span>, right(tmpTrans, 1), 1)
&nbsp;
    tmpStr = Left(tmpTrans, (Len(tmpTrans) - 1)) &amp; right(Left(<span style="color: #800000;">&quot;}JKLMNOPQR&quot;</span>, tmpPos), 1)
   EbcDic = right(tmpFilled &amp; tmpStr, tmpPlaces)
<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://accountingsystems.ie/?feed=rss2&amp;p=24</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Slow Sage on Small Business Server 2003?</title>
		<link>http://accountingsystems.ie/?p=26</link>
		<comments>http://accountingsystems.ie/?p=26#comments</comments>
		<pubDate>Sat, 15 May 2010 19:43:30 +0000</pubDate>
		<dc:creator>Patrick Jones</dc:creator>
				<category><![CDATA[Sage Line 50]]></category>
		<category><![CDATA[Sage]]></category>

		<guid isPermaLink="false">http://accountingsystems.ie/?p=26</guid>
		<description><![CDATA[This is a useful link for sage slowness issues, especially for sbs2003 users
http://www.sbslimited.co.uk/sageslow.htm
]]></description>
			<content:encoded><![CDATA[<p>This is a useful link for sage slowness issues, especially for sbs2003 users</p>
<p><a href="http://www.sbslimited.co.uk/sageslow.htm">http://www.sbslimited.co.uk/sageslow.htm</a></p>
]]></content:encoded>
			<wfw:commentRss>http://accountingsystems.ie/?feed=rss2&amp;p=26</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Loading foreign characters into Syspro</title>
		<link>http://accountingsystems.ie/?p=16</link>
		<comments>http://accountingsystems.ie/?p=16#comments</comments>
		<pubDate>Thu, 06 May 2010 18:38:49 +0000</pubDate>
		<dc:creator>Patrick Jones</dc:creator>
				<category><![CDATA[Syspro]]></category>

		<guid isPermaLink="false">http://accountingsystems.ie/?p=16</guid>
		<description><![CDATA[I had an issue loading address fields with swedish and german characters into syspro via an XML upload so used this function to strip out the characters

Function SpecialReplace(ByVal tmpReg) As String
If Len(tmpReg) &#62; 0 Then
    Dim tmpStr
    'start the replace
    'clear double spaces
    [...]]]></description>
			<content:encoded><![CDATA[<p>I had an issue loading address fields with swedish and german characters into syspro via an XML upload so used this function to strip out the characters</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Function</span> SpecialReplace(<span style="color: #000080;">ByVal</span> tmpReg) <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
<span style="color: #000080;">If</span> Len(tmpReg) &gt; 0 <span style="color: #000080;">Then</span>
    <span style="color: #000080;">Dim</span> tmpStr
    <span style="color: #008000;">'start the replace
</span>    <span style="color: #008000;">'clear double spaces
</span>    tmpStr = Trim(tmpReg)
    tmpStr = FindAndReplace(tmpStr, <span style="color: #800000;">&quot;ä&quot;</span>, <span style="color: #800000;">&quot;a&quot;</span>) <span style="color: #008000;">' ) bracket
</span>    tmpStr = FindAndReplace(tmpStr, <span style="color: #800000;">&quot;Ä&quot;</span>, <span style="color: #800000;">&quot;A&quot;</span>) <span style="color: #008000;">' ) bracket
</span>    tmpStr = FindAndReplace(tmpStr, <span style="color: #800000;">&quot;é&quot;</span>, <span style="color: #800000;">&quot;e&quot;</span>) <span style="color: #008000;">' ) bracket
</span>    tmpStr = FindAndReplace(tmpStr, <span style="color: #800000;">&quot;ö&quot;</span>, <span style="color: #800000;">&quot;o&quot;</span>) <span style="color: #008000;">' ) bracket
</span>    tmpStr = FindAndReplace(tmpStr, <span style="color: #800000;">&quot;Ö&quot;</span>, <span style="color: #800000;">&quot;O&quot;</span>) <span style="color: #008000;">' ) bracket
</span>    tmpStr = FindAndReplace(tmpStr, <span style="color: #800000;">&quot;ü&quot;</span>, <span style="color: #800000;">&quot;u&quot;</span>) <span style="color: #008000;">' ) bracket
</span>    tmpStr = FindAndReplace(tmpStr, <span style="color: #800000;">&quot;Ü&quot;</span>, <span style="color: #800000;">&quot;U&quot;</span>) <span style="color: #008000;">' ) bracket
</span>    tmpStr = FindAndReplace(tmpStr, <span style="color: #800000;">&quot;ß&quot;</span>, <span style="color: #800000;">&quot;s&quot;</span>) <span style="color: #008000;">' ) bracket
</span>    tmpStr = FindAndReplace(tmpStr, <span style="color: #800000;">&quot;Å&quot;</span>, <span style="color: #800000;">&quot;A&quot;</span>)
    tmpStr = FindAndReplace(tmpStr, <span style="color: #800000;">&quot;å&quot;</span>, <span style="color: #800000;">&quot;a&quot;</span>)
    tmpStr = FindAndReplace(tmpStr, <span style="color: #800000;">&quot;Æ&quot;</span>, <span style="color: #800000;">&quot;A&quot;</span>)
    tmpStr = FindAndReplace(tmpStr, <span style="color: #800000;">&quot;æ&quot;</span>, <span style="color: #800000;">&quot;a&quot;</span>)
    tmpStr = FindAndReplace(tmpStr, <span style="color: #800000;">&quot;Ø&quot;</span>, <span style="color: #800000;">&quot;O&quot;</span>)
    SpecialReplace = tmpStr
<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></div></div>

<p>You will need the function below from Alden Streeter</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #008000;">''************ Code Start **********
</span><span style="color: #008000;">'This code was originally written by Alden Streeter.
</span><span style="color: #008000;">'It is not to be altered or distributed,
</span><span style="color: #008000;">'except as part of an application.
</span><span style="color: #008000;">'You are free to use it in any application,
</span><span style="color: #008000;">'provided the copyright notice is left unchanged.
</span><span style="color: #008000;">'
</span><span style="color: #008000;">'Code Courtesy of
</span><span style="color: #008000;">'Alden Streeter
</span><span style="color: #008000;">'
</span><span style="color: #000080;">Function</span> FindAndReplace(<span style="color: #000080;">ByVal</span> strInString <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>, strFindString <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>, strReplaceString <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>) <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
<span style="color: #000080;">Dim</span> intPtr <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>
    <span style="color: #000080;">If</span> Len(strFindString) &amp;gt; 0 <span style="color: #000080;">Then</span>  <span style="color: #008000;">'catch if try to find empty string
</span>        <span style="color: #000080;">Do</span>
            intPtr = InStr(strInString, strFindString)
            <span style="color: #000080;">If</span> intPtr &amp;gt; 0 <span style="color: #000080;">Then</span>
                FindAndReplace = FindAndReplace &amp;amp; Left(strInString, intPtr - 1) &amp;amp; strReplaceString
                    strInString = Mid(strInString, intPtr + Len(strFindString))
            <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
        <span style="color: #000080;">Loop</span> <span style="color: #000080;">While</span> intPtr &amp;gt; 0
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
    FindAndReplace = FindAndReplace &amp;amp; strInString
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://accountingsystems.ie/?feed=rss2&amp;p=16</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Repeating a cell value in Excel</title>
		<link>http://accountingsystems.ie/?p=28</link>
		<comments>http://accountingsystems.ie/?p=28#comments</comments>
		<pubDate>Fri, 30 Apr 2010 18:47:11 +0000</pubDate>
		<dc:creator>Patrick Jones</dc:creator>
				<category><![CDATA[Excel]]></category>

		<guid isPermaLink="false">http://accountingsystems.ie/?p=28</guid>
		<description><![CDATA[This is a request I have had a number of times.. In excel you want to copy the value of the cell above your current position if your current position is blank
To start this macro click on a row 2 or lower with a value in the cell above, change the value of x in [...]]]></description>
			<content:encoded><![CDATA[<p>This is a request I have had a number of times.. In excel you want to copy the value of the cell above your current position if your current position is blank</p>
<p>To start this macro click on a row 2 or lower with a value in the cell above, change the value of x in the macro to the number of lines you want ot repeat</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Sub</span> Macro1()
<span style="color: #008000;">'
</span><span style="color: #008000;">' change the value of x to the number of lines to fill
</span><span style="color: #000080;">Dim</span> I, x
x=1500
<span style="color: #000080;">Do</span> <span style="color: #000080;">While</span> I &lt; x
    <span style="color: #000080;">If</span> ActiveCell.Value = <span style="color: #800000;">&quot;&quot;</span> <span style="color: #000080;">Then</span>
        ActiveCell.Offset(-1, 0).<span style="color: #000080;">Select</span>
        Selection.Copy
        ActiveCell.Offset(1, 0).<span style="color: #000080;">Select</span>
        ActiveSheet.Paste
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
    ActiveCell.Offset(1, 0).<span style="color: #000080;">Select</span>
    I = I + 1
<span style="color: #000080;">Loop</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://accountingsystems.ie/?feed=rss2&amp;p=28</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changing the Vat rates in Sage Line 50</title>
		<link>http://accountingsystems.ie/?p=14</link>
		<comments>http://accountingsystems.ie/?p=14#comments</comments>
		<pubDate>Mon, 26 Apr 2010 18:37:11 +0000</pubDate>
		<dc:creator>Patrick Jones</dc:creator>
				<category><![CDATA[Sage Line 50]]></category>
		<category><![CDATA[Sage]]></category>

		<guid isPermaLink="false">http://accountingsystems.ie/?p=14</guid>
		<description><![CDATA[After we changed the vat for the second time in a year I amended this program to allow the users to change the vat code across customers and products. This version was written for Sage 2009. for the example I have hard coded the tax code but you would use a variable  

Function ChangeVat()
On [...]]]></description>
			<content:encoded><![CDATA[<p>After we changed the vat for the second time in a year I amended this program to allow the users to change the vat code across customers and products. This version was written for Sage 2009. for the example I have hard coded the tax code but you would use a variable <img src='http://accountingsystems.ie/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Function</span> ChangeVat()
<span style="color: #000080;">On</span> <span style="color: #000080;">Error</span> <span style="color: #000080;">GoTo</span> Error_Handler
&nbsp;
DoCmd.Hourglass <span style="color: #000080;">True</span>
<span style="color: #008000;">'check defaults
</span>Application.Echo <span style="color: #000080;">True</span>, <span style="color: #800000;">&quot;Updating Program Data&quot;</span>
&nbsp;
<span style="color: #000080;">Dim</span> oSDO <span style="color: #000080;">As</span> SageDataObject150.SDOEngine
<span style="color: #000080;">Dim</span> oWS <span style="color: #000080;">As</span> SageDataObject150.Workspace
<span style="color: #000080;">Dim</span> strDataPath <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
<span style="color: #000080;">Dim</span> oSalesRecord <span style="color: #000080;">As</span> SageDataObject150.SalesRecord
<span style="color: #000080;">Dim</span> oSalesDeliveryRecord <span style="color: #000080;">As</span> SageDataObject150.SalesDeliveryRecord
<span style="color: #000080;">Dim</span> bFlag <span style="color: #000080;">As</span> <span style="color: #000080;">Boolean</span>
<span style="color: #000080;">Dim</span> i <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>, tmpInt <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, tmpProg <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, tmpCount, tmpLetter <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>, tmpType <span style="color: #000080;">As</span> <span style="color: #000080;">Double</span>
&nbsp;
Application.Echo <span style="color: #000080;">True</span>, <span style="color: #800000;">&quot;Checking for Sage Preferences to Add&quot;</span>
&nbsp;
<span style="color: #000080;">If</span> ChkPrefs = <span style="color: #000080;">False</span> <span style="color: #000080;">Then</span>
    <span style="color: #000080;">GoTo</span> Sage_ExitImport
<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
<span style="color: #008000;">' Create the SDOEngine Object
</span><span style="color: #000080;">Set</span> oSDO = <span style="color: #000080;">New</span> SageDataObject150.SDOEngine
<span style="color: #008000;">' Create the Workspace
</span><span style="color: #000080;">Set</span> oWS = oSDO.Workspaces.Add(<span style="color: #800000;">&quot;Example&quot;</span>)
<span style="color: #008000;">' Select company the select company method
</span>
<span style="color: #008000;">' Connect to Data Files
</span>oWS.Connect <span style="color: #800000;">&quot;Line50 Directory&quot;</span>, <span style="color: #800000;">&quot;Login Name&quot;</span>, <span style="color: #800000;">&quot;Login Password&quot;</span>, <span style="color: #800000;">&quot;Example&quot;</span>
&nbsp;
<span style="color: #008000;">' Create Instance of Sales Record Object
</span><span style="color: #000080;">Set</span> oSalesRecord = oWS.CreateObject(<span style="color: #800000;">&quot;SalesRecord&quot;</span>)
<span style="color: #008000;">' goto the first sales ledger record
</span>
oSalesRecord.MoveFirst
&nbsp;
<span style="color: #000080;">Do</span>
        <span style="color: #008000;">' Edit the Record
</span>        <span style="color: #000080;">If</span> oSalesRecord.Edit <span style="color: #000080;">Then</span>
            <span style="color: #008000;">' Change the Account Name
</span>            oSalesRecord.Fields.Item(<span style="color: #800000;">&quot;DEf_TAX_CODE&quot;</span>).Value = 2
        <span style="color: #008000;">' Update the Record
</span>            <span style="color: #000080;">If</span> oSalesRecord.Update <span style="color: #000080;">Then</span>
                <span style="color: #008000;">' The Update was Successful
</span>                Application.Echo <span style="color: #000080;">True</span>, <span style="color: #800000;">&quot;Account &quot;</span> &amp; oSalesRecord.Fields.Item(<span style="color: #800000;">&quot;ACCOUNT_REF&quot;</span>).Value &amp;<span style="color: #800000;">&quot; was edited successfully.&quot;</span>
            <span style="color: #000080;">Else</span>
                <span style="color: #008000;">' The Update was Unsuccessful
</span>                MsgBox <span style="color: #800000;">&quot;The account could not be edited.&quot;</span>
            <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
        <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
 <span style="color: #000080;">Loop</span> <span style="color: #000080;">Until</span> (<span style="color: #000080;">Not</span> oSalesRecord.MoveNext)
<span style="color: #008000;">'--------------------
</span><span style="color: #008000;">'Export the Products
</span><span style="color: #008000;">'------------------
</span><span style="color: #000080;">Dim</span> oStockRecord <span style="color: #000080;">As</span> SageDataObject150.StockRecord
<span style="color: #000080;">Dim</span> oPriceRecord <span style="color: #000080;">As</span> SageDataObject150.PriceRecord
<span style="color: #000080;">Dim</span> oControlData <span style="color: #000080;">As</span> SageDataObject150.ControlData
&nbsp;
<span style="color: #008000;">' Create Instance of StockRecord Object
</span><span style="color: #000080;">Set</span> oStockRecord = oWS.CreateObject(<span style="color: #800000;">&quot;StockRecord&quot;</span>)
<span style="color: #000080;">Set</span> oPriceRecord = oWS.CreateObject(<span style="color: #800000;">&quot;PriceRecord&quot;</span>)
tmpCount = oStockRecord.Count
tmpProg = 1
oStockRecord.MoveFirst
<span style="color: #000080;">Do</span>
&nbsp;
        <span style="color: #008000;">' Edit the Record
</span>        <span style="color: #000080;">If</span> oStockRecord.Edit <span style="color: #000080;">Then</span>
            oStockRecord.Fields.Item(<span style="color: #800000;">&quot;TAX_CODE&quot;</span>).Value = 2
        <span style="color: #008000;">' Update the Record
</span>            <span style="color: #000080;">If</span> oStockRecord.Update <span style="color: #000080;">Then</span>
                <span style="color: #008000;">' The Update was Successful
</span>                Application.Echo <span style="color: #000080;">True</span>, <span style="color: #800000;">&quot;Account &quot;</span> &amp; oStockRecord.Fields.Item(<span style="color: #800000;">&quot;STOCK_CODE&quot;</span>).Value &amp; <span style="color: #800000;">&quot; was edited successfully.&quot;</span>
            <span style="color: #000080;">Else</span>
                <span style="color: #008000;">' The Update was Unsuccessful
</span>                MsgBox <span style="color: #800000;">&quot;The account could not be edited.&quot;</span>
            <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
        <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
<span style="color: #000080;">Loop</span> <span style="color: #000080;">Until</span> (<span style="color: #000080;">Not</span> oStockRecord.MoveNext)
&nbsp;
<span style="color: #008000;">'Close connections
</span><span style="color: #000080;">Set</span> oStockRecord = <span style="color: #000080;">Nothing</span>
<span style="color: #000080;">Set</span> oControlData = <span style="color: #000080;">Nothing</span>
&nbsp;
Sage_ExitImport:
&nbsp;
<span style="color: #008000;">' Disconnect and Destroy the Objects
</span>oWS.Disconnect
<span style="color: #000080;">Set</span> oSalesRecord = <span style="color: #000080;">Nothing</span>
<span style="color: #000080;">Set</span> oSDO = <span style="color: #000080;">Nothing</span>
<span style="color: #000080;">Set</span> oWS = <span style="color: #000080;">Nothing</span>
DoCmd.Hourglass <span style="color: #000080;">False</span>
&nbsp;
<span style="color: #000080;">Exit</span> <span style="color: #000080;">Function</span>
&nbsp;
<span style="color: #008000;">' Error Handling Code
</span>Error_Handler:
<span style="color: #000080;">Call</span> SageError(oSDO.LastError.Code, oSDO.LastError.text, Err.Number, Err.Description, <span style="color: #800000;">&quot;Sage Import&quot;</span>)
&nbsp;
DoCmd.Hourglass <span style="color: #000080;">False</span>
<span style="color: #000080;">Resume</span> Sage_ExitImport
&nbsp;
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://accountingsystems.ie/?feed=rss2&amp;p=14</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Date Difference in Excel</title>
		<link>http://accountingsystems.ie/?p=47</link>
		<comments>http://accountingsystems.ie/?p=47#comments</comments>
		<pubDate>Fri, 23 Apr 2010 11:36:05 +0000</pubDate>
		<dc:creator>Patrick Jones</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://accountingsystems.ie/?p=47</guid>
		<description><![CDATA[I have used datediff in access and vba but didnt not know that excel had the function DateDif which is very useful function in pay budgeting models.
See the link here for details
]]></description>
			<content:encoded><![CDATA[<p>I have used datediff in access and vba but didnt not know that excel had the function DateDif which is very useful function in pay budgeting models.</p>
<p>See the link <a href="http://www.cpearson.com/excel/datedif.aspx">here</a> for details</p>
]]></content:encoded>
			<wfw:commentRss>http://accountingsystems.ie/?feed=rss2&amp;p=47</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Posting Invoices into Sage Line 50 from an Access Database</title>
		<link>http://accountingsystems.ie/?p=12</link>
		<comments>http://accountingsystems.ie/?p=12#comments</comments>
		<pubDate>Mon, 12 Apr 2010 18:35:53 +0000</pubDate>
		<dc:creator>Patrick Jones</dc:creator>
				<category><![CDATA[Sage Line 50]]></category>
		<category><![CDATA[Sage]]></category>

		<guid isPermaLink="false">http://accountingsystems.ie/?p=12</guid>
		<description><![CDATA[Sage Line 50 allows direct read/write access to many of the tables in Sage through the Sage Data Objects. To use this you will need to have the file sd0engxx0.tlb where xx is the sage version number.
2 keys issues I have had in loading data into sage
1. Ensure the values passed to Sage are not [...]]]></description>
			<content:encoded><![CDATA[<p>Sage Line 50 allows direct read/write access to many of the tables in Sage through the Sage Data Objects. To use this you will need to have the file sd0engxx0.tlb where xx is the sage version number.</p>
<p>2 keys issues I have had in loading data into sage</p>
<p>1. Ensure the values passed to Sage are not null, convert your values to strings where appropriate<br />
2. The values passed to Sage are not longer than the field width</p>
<p>Sounds obvious but I missed both of these in earlier program versions.</p>
<p>The following Sample shows an invoice been posted from an access table to Sage.</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">&nbsp;
<span style="color: #000080;">Function</span> fncCreateInvoices(<span style="color: #000080;">ByVal</span> tmpDate <span style="color: #000080;">As</span> <span style="color: #000080;">Date</span>)
&nbsp;
<span style="color: #000080;">On</span> <span style="color: #000080;">Error</span> <span style="color: #000080;">GoTo</span> Error_Handler
&nbsp;
<span style="color: #008000;">'i use the date passed to filter the invoice table from MASC
</span><span style="color: #000080;">If</span> <span style="color: #000080;">Not</span> IsDate(tmpDate) <span style="color: #000080;">Then</span>
    MsgBox <span style="color: #800000;">&quot;Please enter a valid date&quot;</span>
    <span style="color: #000080;">Exit</span> <span style="color: #000080;">Function</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
DoCmd.Hourglass <span style="color: #000080;">True</span>
&nbsp;
<span style="color: #008000;">' Declare Objects
</span><span style="color: #000080;">Dim</span> oSDO <span style="color: #000080;">As</span> SageDataObject120.SDOEngine
<span style="color: #000080;">Dim</span> oWS <span style="color: #000080;">As</span> SageDataObject120.Workspace
<span style="color: #000080;">Dim</span> oInvoicePost <span style="color: #000080;">As</span> SageDataObject120.InvoicePost
<span style="color: #000080;">Dim</span> oInvoiceItem <span style="color: #000080;">As</span> SageDataObject120.InvoiceItem
<span style="color: #000080;">Dim</span> oSalesRecord <span style="color: #000080;">As</span> SageDataObject120.SalesRecord
<span style="color: #000080;">Dim</span> oStockRecord <span style="color: #000080;">As</span> SageDataObject120.StockRecord
<span style="color: #000080;">Dim</span> oSalesDeliveryRecord <span style="color: #000080;">As</span> SageDataObject120.SalesDeliveryRecord
&nbsp;
<span style="color: #000080;">Dim</span> db <span style="color: #000080;">As</span> Database
<span style="color: #000080;">Dim</span> rstSource <span style="color: #000080;">As</span> Recordset, rstTrans <span style="color: #000080;">As</span> Recordset, strAccount
<span style="color: #000080;">Dim</span> tmpTranCust, tmpUseON <span style="color: #000080;">As</span> <span style="color: #000080;">Boolean</span>, tmpTranDD <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>, tmpUseCPO <span style="color: #000080;">As</span> <span style="color: #000080;">Boolean</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #000080;">Set</span> db = CurrentDb
&nbsp;
<span style="color: #008000;">' Declare Variables
</span><span style="color: #000080;">Dim</span> strDataPath <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
<span style="color: #000080;">Dim</span> bFlag <span style="color: #000080;">As</span> <span style="color: #000080;">Boolean</span>
<span style="color: #000080;">Dim</span> iCtr <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>
&nbsp;
<span style="color: #008000;">'sage initialise
</span><span style="color: #008000;">' Create the SDO Engine Object
</span><span style="color: #000080;">Set</span> oSDO = <span style="color: #000080;">New</span> SageDataObject120.SDOEngine
&nbsp;
<span style="color: #008000;">' Create the Workspace
</span><span style="color: #000080;">Set</span> oWS = oSDO.Workspaces.Add(<span style="color: #800000;">&quot;Example&quot;</span>)
&nbsp;
<span style="color: #008000;">'Check that the selected invoices have a customer record See older posts for Actdate
</span><span style="color: #000080;">Set</span> rstSource = db.OpenRecordset(<span style="color: #800000;">&quot;select * from QryCheckInvDates where tDate&lt;=#&quot;</span> &amp; ActDate(tmpDate) &amp; <span style="color: #800000;">&quot;#&quot;</span>)
Application.Echo <span style="color: #000080;">True</span>, <span style="color: #800000;">&quot;Checking Customers&quot;</span>
<span style="color: #000080;">If</span> rstSource.RecordCount &gt; 0 <span style="color: #000080;">Then</span>
  <span style="color: #000080;">If</span> MsgBox(<span style="color: #800000;">&quot;Some customer records are missing in sage, print a listing ?&quot;</span>, vbYesNo) = vbYes <span style="color: #000080;">Then</span>
      DoCmd.OpenReport <span style="color: #800000;">&quot;rptMissingCustomers&quot;</span>, acViewPreview
      <span style="color: #000080;">GoTo</span> Exit_Function
  <span style="color: #000080;">Else</span>
      MsgBox <span style="color: #800000;">&quot;Add the new customers to proceed&quot;</span>
      <span style="color: #000080;">GoTo</span> Exit_Function
  <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
Application.Echo <span style="color: #000080;">True</span>, <span style="color: #800000;">&quot;Checking for Invoices to Add&quot;</span>
<span style="color: #008000;">' create export code
</span><span style="color: #000080;">Set</span> rstSource = db.OpenRecordset(<span style="color: #800000;">&quot;select * from qryInvoicestoExport where Value&gt;0 and tDate&lt;=#&quot;</span> &amp; ActDate(tmpDate) &amp; <span style="color: #800000;">&quot;# ORDER by Ref ASC&quot;</span>)
<span style="color: #000080;">If</span> rstSource.RecordCount = 0 <span style="color: #000080;">Then</span>
      MsgBox <span style="color: #800000;">&quot;Nothing to process&quot;</span>
      <span style="color: #000080;">GoTo</span> Exit_Function
<span style="color: #000080;">Else</span>
  rstSource.MoveFirst
<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
Application.Echo <span style="color: #000080;">True</span>, <span style="color: #800000;">&quot;Checking for Sage Preferences to Add&quot;</span>
&nbsp;
<span style="color: #000080;">If</span> ChkPrefs = <span style="color: #000080;">False</span> <span style="color: #000080;">Then</span>
    <span style="color: #000080;">GoTo</span> Exit_Function
<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
<span style="color: #008000;">' Connect to Data Files
</span>oWS.Connect <span style="color: #800000;">&quot;Line50 Directory&quot;</span>,<span style="color: #800000;">&quot;Login Name&quot;</span>,<span style="color: #800000;">&quot;Login Password&quot;</span>, <span style="color: #800000;">&quot;Example&quot;</span>
&nbsp;
Application.Echo <span style="color: #000080;">True</span>, <span style="color: #800000;">&quot;Connected to Sage&quot;</span>
&nbsp;
<span style="color: #008000;">'loop the record source
</span><span style="color: #000080;">Do</span> <span style="color: #000080;">While</span> <span style="color: #000080;">Not</span> rstSource.EOF
&nbsp;
<span style="color: #008000;">' Create an instance of InvoicePost &amp; Record object's
</span> <span style="color: #000080;">Set</span> oSalesRecord = oWS.CreateObject(<span style="color: #800000;">&quot;SalesRecord&quot;</span>)
 <span style="color: #000080;">Set</span> oInvoicePost = oWS.CreateObject(<span style="color: #800000;">&quot;InvoicePost&quot;</span>)
 <span style="color: #000080;">Set</span> oStockRecord = oWS.CreateObject(<span style="color: #800000;">&quot;StockRecord&quot;</span>)
&nbsp;
&nbsp;
&nbsp;
 <span style="color: #008000;">' Set the type of invoice for the next available number
</span> oInvoicePost.<span style="color: #000080;">Type</span> = sdoLedgerInvoice
&nbsp;
 <span style="color: #008000;">'get the transactions
</span> <span style="color: #000080;">Set</span> rstTrans = db.OpenRecordset(<span style="color: #800000;">&quot;Select * from qryTrans Where hInvoiceno=&quot;</span> &amp; rstSource!REF)
 <span style="color: #000080;">If</span> rstTrans.RecordCount = 0 <span style="color: #000080;">Then</span>
   MsgBox <span style="color: #800000;">&quot;No Transactions for invoice &quot;</span> &amp; rstSource!REF
   <span style="color: #000080;">GoTo</span> loop_routine
 <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
 Application.Echo <span style="color: #000080;">True</span>, <span style="color: #800000;">&quot;Processing Invoice &quot;</span> &amp; rstSource!REF
&nbsp;
&nbsp;
&nbsp;
 <span style="color: #008000;">' Use the invoice number assigned from masc
</span> oInvoicePost.Header(<span style="color: #800000;">&quot;Invoice_Number&quot;</span>) = rstSource!REF
&nbsp;
 <span style="color: #008000;">' Loop for Number of Items on the Invoice
</span>       iCtr = 0
       tmpTranCust = <span style="color: #800000;">&quot;&quot;</span>
       <span style="color: #000080;">Do</span> <span style="color: #000080;">While</span> <span style="color: #000080;">Not</span> rstTrans.EOF
&nbsp;
           <span style="color: #000080;">Set</span> oInvoiceItem = oInvoicePost.Items.Add()
         iCtr = iCtr + 1
&nbsp;
         <span style="color: #008000;">' Initialise Index Field with value to search
</span>         oStockRecord(<span style="color: #800000;">&quot;Stock_CODE&quot;</span>) = <span style="color: #000080;">CStr</span>(rstTrans!HprodC)
         <span style="color: #000080;">If</span> oSalesRecord.Find(<span style="color: #000080;">False</span>) <span style="color: #000080;">Then</span>
           oInvoiceItem(<span style="color: #800000;">&quot;Stock_Code&quot;</span>) = <span style="color: #000080;">CStr</span>(oStockRecord(<span style="color: #800000;">&quot;Stock_Code&quot;</span>))
           oInvoiceItem(<span style="color: #800000;">&quot;Description&quot;</span>) = nullCstr(rstTrans!HInvText)
           oInvoiceItem(<span style="color: #800000;">&quot;Comment_1&quot;</span>) = nullCstr(rstTrans!HInvText)
           oInvoiceItem(<span style="color: #800000;">&quot;Nominal_Code&quot;</span>) = <span style="color: #000080;">CStr</span>(oStockRecord(<span style="color: #800000;">&quot;Nominal_Code&quot;</span>))
           oInvoiceItem(<span style="color: #800000;">&quot;Tax_Code&quot;</span>) = <span style="color: #000080;">CInt</span>(Right(rstTrans!HVatRate, 1))
         <span style="color: #000080;">Else</span>
           oInvoiceItem(<span style="color: #800000;">&quot;Stock_Code&quot;</span>) = <span style="color: #000080;">CStr</span>(rstTrans!HprodC)
           oInvoiceItem(<span style="color: #800000;">&quot;Description&quot;</span>) = nullCstr(rstTrans!HInvText)
           oInvoiceItem(<span style="color: #800000;">&quot;Comment_1&quot;</span>) = nullCstr(rstTrans!HInvText)
           oInvoiceItem(<span style="color: #800000;">&quot;Nominal_Code&quot;</span>) = <span style="color: #000080;">CStr</span>(GetPref(<span style="color: #800000;">&quot;Default Sales Nominal&quot;</span>))
           oInvoiceItem(<span style="color: #800000;">&quot;Tax_Code&quot;</span>) = <span style="color: #000080;">CInt</span>(Right(rstTrans!HVatRate, 1))
         <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
         <span style="color: #008000;">' Populate other fields required for Invoice Item
</span>         oInvoiceItem(<span style="color: #800000;">&quot;Qty_Order&quot;</span>) = <span style="color: #000080;">CDbl</span>(rstTrans!HQty)
         oInvoiceItem(<span style="color: #800000;">&quot;Unit_Price&quot;</span>) = <span style="color: #000080;">CDbl</span>(rstTrans!HPrice)
         oInvoiceItem(<span style="color: #800000;">&quot;Net_Amount&quot;</span>) = <span style="color: #000080;">CDbl</span>(rstTrans!HLineValue)
         oInvoiceItem(<span style="color: #800000;">&quot;Tax_Amount&quot;</span>) = <span style="color: #000080;">CDbl</span>(rstTrans!HVatVal)
         oInvoiceItem(<span style="color: #800000;">&quot;Comment_2&quot;</span>) = <span style="color: #000080;">CStr</span>(<span style="color: #800000;">&quot;Date:&quot;</span> &amp; Format(rstTrans!HDATE, <span style="color: #800000;">&quot;dd/mm/yy&quot;</span>))
         oInvoiceItem(<span style="color: #800000;">&quot;Unit_Of_Sale&quot;</span>) = <span style="color: #000080;">CStr</span>(<span style="color: #800000;">&quot;&quot;</span>)
         oInvoiceItem(<span style="color: #800000;">&quot;Full_Net_Amount&quot;</span>) = <span style="color: #000080;">CDbl</span>(rstTrans!HVatVal + rstTrans!HLineValue)
         oInvoiceItem(<span style="color: #800000;">&quot;Tax_Rate&quot;</span>) = <span style="color: #000080;">CDbl</span>(rstTrans!VT_Rate)
         tmpTranCust = rstTrans!HCustCode
         tmpTranDD = nullCstr(rstTrans!HSuppref)
         rstTrans.MoveNext
      <span style="color: #000080;">Loop</span> <span style="color: #008000;">' on trans
</span>
&nbsp;
 <span style="color: #008000;">' Populate Invoice Header Information
</span> oInvoicePost.Header(<span style="color: #800000;">&quot;Invoice_Date&quot;</span>) = <span style="color: #000080;">CDate</span>(rstSource!TDate)
 oInvoicePost.Header(<span style="color: #800000;">&quot;Notes_1&quot;</span>) = <span style="color: #000080;">CStr</span>(<span style="color: #800000;">&quot;&quot;</span>)
 oInvoicePost.Header(<span style="color: #800000;">&quot;Notes_2&quot;</span>) = <span style="color: #000080;">CStr</span>(<span style="color: #800000;">&quot;&quot;</span>)
 oInvoicePost.Header(<span style="color: #800000;">&quot;Notes_3&quot;</span>) = <span style="color: #000080;">CStr</span>(<span style="color: #800000;">&quot;&quot;</span>)
 oInvoicePost.Header(<span style="color: #800000;">&quot;Taken_By&quot;</span>) = <span style="color: #000080;">CStr</span>(<span style="color: #800000;">&quot;&quot;</span>)
 oInvoicePost.Header(<span style="color: #800000;">&quot;Order_Number&quot;</span>) = IIf(tmpUseON, Left(<span style="color: #000080;">CStr</span>(tmpTranDD), 7), <span style="color: #800000;">&quot;&quot;</span>)
 oInvoicePost.Header(<span style="color: #800000;">&quot;Cust_Order_Number&quot;</span>) = IIf(tmpUseCPO, Left(<span style="color: #000080;">CStr</span>(tmpTranDD), 7), <span style="color: #800000;">&quot;&quot;</span>)
 oInvoicePost.Header(<span style="color: #800000;">&quot;Payment_Ref&quot;</span>) = <span style="color: #000080;">CStr</span>(<span style="color: #800000;">&quot;&quot;</span>)
 oInvoicePost.Header(<span style="color: #800000;">&quot;Global_Nom_Code&quot;</span>) = <span style="color: #000080;">CStr</span>(<span style="color: #800000;">&quot;&quot;</span>)
 oInvoicePost.Header(<span style="color: #800000;">&quot;Global_Details&quot;</span>) = <span style="color: #000080;">CStr</span>(<span style="color: #800000;">&quot;&quot;</span>)
 oInvoicePost.Header(<span style="color: #800000;">&quot;Invoice_Type_Code&quot;</span>) = <span style="color: #000080;">CByte</span>(sdoProductInvoice)
 oInvoicePost.Header(<span style="color: #800000;">&quot;Items_Net&quot;</span>) = <span style="color: #000080;">CDbl</span>(rstSource!InvNet)
 oInvoicePost.Header(<span style="color: #800000;">&quot;Items_Tax&quot;</span>) = <span style="color: #000080;">CDbl</span>(rstSource!InvVat)
&nbsp;
 <span style="color: #008000;">' Read the first customer
</span> strAccount = <span style="color: #000080;">CStr</span>(rstSource!ID)
 strAccount = strAccount &amp; <span style="color: #000080;">String</span>(8 - Len(strAccount), 32)
 oSalesRecord(<span style="color: #800000;">&quot;Account_Ref&quot;</span>) = strAccount
&nbsp;
 bFlag = oSalesRecord.Find(<span style="color: #000080;">False</span>) <span style="color: #008000;">'(&quot;ACCOUNT_REF&quot;, strAccount)
</span> <span style="color: #000080;">If</span> bFlag <span style="color: #000080;">Then</span>
 oInvoicePost.Header(<span style="color: #800000;">&quot;Account_Ref&quot;</span>) = <span style="color: #000080;">CStr</span>(rstSource!ID) <span style="color: #008000;">'oSalesRecord(&quot;Account_Ref&quot;))
</span> oInvoicePost.Header(<span style="color: #800000;">&quot;Name&quot;</span>) = <span style="color: #000080;">CStr</span>(oSalesRecord(<span style="color: #800000;">&quot;Name&quot;</span>))
 oInvoicePost.Header(<span style="color: #800000;">&quot;Address_1&quot;</span>) = <span style="color: #000080;">CStr</span>(oSalesRecord(<span style="color: #800000;">&quot;Address_1&quot;</span>))
 oInvoicePost.Header(<span style="color: #800000;">&quot;Address_2&quot;</span>) = <span style="color: #000080;">CStr</span>(oSalesRecord(<span style="color: #800000;">&quot;Address_2&quot;</span>))
 oInvoicePost.Header(<span style="color: #800000;">&quot;Address_3&quot;</span>) = <span style="color: #000080;">CStr</span>(oSalesRecord(<span style="color: #800000;">&quot;Address_3&quot;</span>))
 oInvoicePost.Header(<span style="color: #800000;">&quot;Address_4&quot;</span>) = <span style="color: #000080;">CStr</span>(oSalesRecord(<span style="color: #800000;">&quot;Address_4&quot;</span>))
 oInvoicePost.Header(<span style="color: #800000;">&quot;Address_5&quot;</span>) = <span style="color: #000080;">CStr</span>(oSalesRecord(<span style="color: #800000;">&quot;Address_5&quot;</span>))
 <span style="color: #000080;">Set</span> oSalesDeliveryRecord = oWS.CreateObject(<span style="color: #800000;">&quot;SalesDeliveryRecord&quot;</span>)
 <span style="color: #000080;">Dim</span> bEnd
 bEnd = <span style="color: #000080;">False</span>
 <span style="color: #000080;">If</span> <span style="color: #000080;">Not</span> IsNull(tmpTranCust) <span style="color: #000080;">Or</span> Len(tmpTranCust) &lt;&gt; 0 <span style="color: #000080;">Then</span>
   oSalesDeliveryRecord.MoveFirst
   <span style="color: #000080;">Do</span>
       <span style="color: #000080;">If</span> oSalesDeliveryRecord(<span style="color: #800000;">&quot;DESCRIPTION&quot;</span>) = tmpTranCust <span style="color: #000080;">Then</span>
         bEnd = <span style="color: #000080;">True</span>
         oInvoicePost.Header(<span style="color: #800000;">&quot;DELIVERY_NAME&quot;</span>) = <span style="color: #000080;">CStr</span>(oSalesDeliveryRecord(<span style="color: #800000;">&quot;NAME&quot;</span>))
         oInvoicePost.Header(<span style="color: #800000;">&quot;Del_Address_1&quot;</span>) = <span style="color: #000080;">CStr</span>(oSalesDeliveryRecord(<span style="color: #800000;">&quot;Address_1&quot;</span>))
         oInvoicePost.Header(<span style="color: #800000;">&quot;Del_Address_2&quot;</span>) = <span style="color: #000080;">CStr</span>(oSalesDeliveryRecord(<span style="color: #800000;">&quot;Address_2&quot;</span>))
         oInvoicePost.Header(<span style="color: #800000;">&quot;Del_Address_3&quot;</span>) = <span style="color: #000080;">CStr</span>(oSalesDeliveryRecord(<span style="color: #800000;">&quot;Address_3&quot;</span>))
         oInvoicePost.Header(<span style="color: #800000;">&quot;Del_Address_4&quot;</span>) = <span style="color: #000080;">CStr</span>(oSalesDeliveryRecord(<span style="color: #800000;">&quot;Address_4&quot;</span>))
         oInvoicePost.Header(<span style="color: #800000;">&quot;Del_Address_5&quot;</span>) = <span style="color: #000080;">CStr</span>(oSalesDeliveryRecord(<span style="color: #800000;">&quot;Address_5&quot;</span>))
         oInvoicePost.Header(<span style="color: #800000;">&quot;Cust_Tel_Number&quot;</span>) = <span style="color: #000080;">CStr</span>(oSalesDeliveryRecord(<span style="color: #800000;">&quot;Telephone&quot;</span>))
         oInvoicePost.Header(<span style="color: #800000;">&quot;Contact_Name&quot;</span>) = <span style="color: #000080;">CStr</span>(oSalesDeliveryRecord(<span style="color: #800000;">&quot;Contact_Name&quot;</span>))
       <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
   <span style="color: #000080;">Loop</span> <span style="color: #000080;">Until</span> (bEnd <span style="color: #000080;">Or</span> <span style="color: #000080;">Not</span> oSalesDeliveryRecord.MoveNext)
&nbsp;
<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
 <span style="color: #008000;">' Update the Invoice
</span> bFlag = oInvoicePost.Update
 <span style="color: #000080;">If</span> bFlag <span style="color: #000080;">Then</span>
   Application.Echo <span style="color: #000080;">True</span>, <span style="color: #800000;">&quot;Invoice Created Successfully :&quot;</span> &amp; rstSource!REF
   db.Execute (<span style="color: #800000;">&quot;Update tblbillings set ar_PRocessed=-1 where ref=&quot;</span> &amp; rstSource!REF)
 <span style="color: #000080;">Else</span>
   Application.Echo <span style="color: #000080;">True</span>, <span style="color: #800000;">&quot;Invoice Not Created&quot;</span>
 <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
loop_routine:
&nbsp;
rstSource.MoveNext
&nbsp;
<span style="color: #000080;">Set</span> oSalesRecord = <span style="color: #000080;">Nothing</span>
<span style="color: #000080;">Set</span> oInvoicePost = <span style="color: #000080;">Nothing</span>
<span style="color: #000080;">Set</span> oInvoiceItem = <span style="color: #000080;">Nothing</span>
<span style="color: #000080;">Set</span> oSalesDeliveryRecord = <span style="color: #000080;">Nothing</span>
&nbsp;
&nbsp;
<span style="color: #000080;">Loop</span> <span style="color: #008000;">' on rstsource
</span>
&nbsp;
Exit_Function:
&nbsp;
<span style="color: #008000;">' Disconnect and Destroy Objects
</span>oWS.Disconnect
<span style="color: #000080;">Set</span> oSDO = <span style="color: #000080;">Nothing</span>
<span style="color: #000080;">Set</span> oWS = <span style="color: #000080;">Nothing</span>
<span style="color: #000080;">Set</span> db = <span style="color: #000080;">Nothing</span>
<span style="color: #000080;">Set</span> rstSource = <span style="color: #000080;">Nothing</span>
<span style="color: #000080;">Set</span> rstTrans = <span style="color: #000080;">Nothing</span>
&nbsp;
DoCmd.Hourglass <span style="color: #000080;">False</span>
&nbsp;
<span style="color: #000080;">Exit</span> <span style="color: #000080;">Function</span>
<span style="color: #008000;">' Error Handling Code
</span>Error_Handler:
<span style="color: #000080;">Call</span> SageError(oSDO.LastError.Code, oSDO.LastError.Text, Err.Number, Err.Description, <span style="color: #800000;">&quot;Sage Invoice Export&quot;</span>)
&nbsp;
DoCmd.Hourglass <span style="color: #000080;">False</span>
<span style="color: #000080;">Resume</span> Exit_Function
&nbsp;
&nbsp;
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://accountingsystems.ie/?feed=rss2&amp;p=12</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Posting Sales Orders in Syspro using XML and Business Objects</title>
		<link>http://accountingsystems.ie/?p=8</link>
		<comments>http://accountingsystems.ie/?p=8#comments</comments>
		<pubDate>Sat, 10 Apr 2010 18:32:22 +0000</pubDate>
		<dc:creator>Patrick Jones</dc:creator>
				<category><![CDATA[Syspro]]></category>

		<guid isPermaLink="false">http://accountingsystems.ie/?p=8</guid>
		<description><![CDATA[The task criteria was to load orders from field sales office by adding automation to Excel files or loading XML files into an access database. This allows the client to validate the order entries and ensure all key data is present before attempting to load the orders into Syspro.
This post covers the export of the [...]]]></description>
			<content:encoded><![CDATA[<p>The task criteria was to load orders from field sales office by adding automation to Excel files or loading XML files into an access database. This allows the client to validate the order entries and ensure all key data is present before attempting to load the orders into Syspro.</p>
<p>This post covers the export of the data from the validated database into Syspro.</p>
<p>To use this code you would need to download and install the free ChilkatXML program see <a href="http://www.chilkatsoft.com" target="_blank">chilkatsoft.com</a> and add a reference to Chilkat XML, DAO 3.6 and Syspro e.Net.</p>
<p>If you any questions on how to use this code please post a question</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Function</span> ExportXML()
<span style="color: #008000;">' this function will use a validated export table of data to create the xml file
</span><span style="color: #008000;">'and pass this file to be executed by Syspro
</span><span style="color: #008000;">'Structure creted on 3-Apr
</span><span style="color: #000080;">Dim</span> xml <span style="color: #000080;">As</span> <span style="color: #000080;">New</span> ChilkatXml
<span style="color: #000080;">Dim</span> HeaderNode <span style="color: #000080;">As</span> ChilkatXml
<span style="color: #000080;">Dim</span> OrderNode <span style="color: #000080;">As</span> ChilkatXml
<span style="color: #000080;">Dim</span> OrderHeaderNode <span style="color: #000080;">As</span> ChilkatXml
<span style="color: #000080;">Dim</span> OrderDetailsNode <span style="color: #000080;">As</span> ChilkatXml
<span style="color: #000080;">Dim</span> OrderDetailsStockLineNode <span style="color: #000080;">As</span> ChilkatXml
<span style="color: #000080;">Dim</span> OrderDetailsCommentLineNode <span style="color: #000080;">As</span> ChilkatXml
<span style="color: #000080;">Dim</span> OrderDetailsMiscChargeLineNode <span style="color: #000080;">As</span> ChilkatXml
<span style="color: #000080;">Dim</span> OrderDetailsFreightLineNode <span style="color: #000080;">As</span> ChilkatXml
&nbsp;
<span style="color: #000080;">Dim</span> tmpOrderNumber, tmpEntityNumber, tmpOrderLine
<span style="color: #000080;">Dim</span> rst <span style="color: #000080;">As</span> Recordset
&nbsp;
<span style="color: #000080;">Set</span> HeaderNode = xml.NewChild(<span style="color: #800000;">&quot;TransmissionHeader&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>)
<span style="color: #000080;">Set</span> OrderNode = xml.NewChild(<span style="color: #800000;">&quot;Orders&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>)
&nbsp;
xml.Tag = <span style="color: #800000;">&quot;SalesOrders&quot;</span>
<span style="color: #008000;">'set the header values
</span>HeaderNode.NewChild2 <span style="color: #800000;">&quot;TransmissionReference&quot;</span>, <span style="color: #800000;">&quot;000003&quot;</span>     <span style="color: #008000;">'rst!ID 'use the id of the passed recordset
</span>HeaderNode.NewChild2 <span style="color: #800000;">&quot;SenderCode&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
HeaderNode.NewChild2 <span style="color: #800000;">&quot;ReceiverCode&quot;</span>, <span style="color: #800000;">&quot;HO&quot;</span>
HeaderNode.NewChild2 <span style="color: #800000;">&quot;DatePRepared&quot;</span>, Format(<span style="color: #000080;">Date</span>, <span style="color: #800000;">&quot;yyyy-mm-dd&quot;</span>)
HeaderNode.NewChild2 <span style="color: #800000;">&quot;TimePrepared&quot;</span>, Format(Now(), <span style="color: #800000;">&quot;hh:nn&quot;</span>)
&nbsp;
<span style="color: #000080;">Set</span> rst = CurrentDb.OpenRecordset(<span style="color: #800000;">&quot;qryImportData_Filtered&quot;</span>) <span style="color: #008000;">' this is a filtered list of the record to upload
</span><span style="color: #000080;">If</span> rst.RecordCount = 0 <span style="color: #000080;">Then</span>
    MsgBox <span style="color: #800000;">&quot;Nothing to Process&quot;</span>
    <span style="color: #000080;">GoTo</span> Exit_Func
    <span style="color: #000080;">Exit</span> <span style="color: #000080;">Function</span>
<span style="color: #000080;">Else</span>
    rst.MoveFirst
<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
tmpEntityNumber = <span style="color: #800000;">&quot;&quot;</span>
tmpOrderNumber = <span style="color: #800000;">&quot;&quot;</span>
tmpOrderLine = 1
&nbsp;
<span style="color: #008000;">'Set OrderHeaderNode = OrderNode.NewChild(&quot;OrderHeader&quot;, &quot;&quot;)
</span>
<span style="color: #000080;">Do</span> <span style="color: #000080;">While</span> <span style="color: #000080;">Not</span> rst.EOF
&nbsp;
<span style="color: #000080;">If</span> tmpEntityNumber &lt;&gt; rst!O_Entity <span style="color: #000080;">Or</span> tmpOrderNumber &lt;&gt; rst!O_Number <span style="color: #000080;">Then</span>
    <span style="color: #008000;">'Must be a new order - write the header data and fill the static details
</span>    <span style="color: #000080;">Set</span> OrderHeaderNode = OrderNode.NewChild(<span style="color: #800000;">&quot;OrderHeader&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>)
    <span style="color: #000080;">Set</span> OrderDetailsNode = OrderNode.NewChild(<span style="color: #800000;">&quot;OrderDetails&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>)
&nbsp;
    tmpEntityNumber = rst!O_Entity
    tmpOrderNumber = rst!O_Number
    tmpOrderLine = 1
&nbsp;
    <span style="color: #008000;">'Add the order header values
</span>    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;CustomerPoNumber&quot;</span>, rst!O_Number     <span style="color: #008000;">'get from recordset
</span>    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;OrderActionType&quot;</span>, tmpOrderActionType     <span style="color: #008000;">'get from variables
</span>    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;NewCustomerPoNumber&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;Supplier&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;Customer&quot;</span>, rst!O_Entity
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;OrderDate&quot;</span>, Format(<span style="color: #000080;">Date</span>, <span style="color: #800000;">&quot;yyyy-mm-dd&quot;</span>)
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;InvoiceTerms&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;Currency&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;ShippingInstrs&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;CustomerName&quot;</span>, Left(rst!O_ShipName &amp; <span style="color: #800000;">&quot;&quot;</span>, 30)
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;ShipAddress1&quot;</span>, Left(rst!O_Ship1 &amp; <span style="color: #800000;">&quot;&quot;</span>, 40)
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;ShipAddress2&quot;</span>, Left(rst!O_Ship2 &amp; <span style="color: #800000;">&quot;&quot;</span>, 40)
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;ShipAddress3&quot;</span>, Left(rst!O_Ship3 &amp; <span style="color: #800000;">&quot;&quot;</span>, 40)
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;ShipAddress4&quot;</span>, Left(rst!O_Ship4 &amp; <span style="color: #800000;">&quot;&quot;</span>, 40)
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;ShipAddress5&quot;</span>, Left(rst!O_Ship5 &amp; <span style="color: #800000;">&quot;&quot;</span>, 40)
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;ShipPostalCode&quot;</span>, Left(rst!O_Ship6 &amp; <span style="color: #800000;">&quot;&quot;</span>, 9) <span style="color: #008000;">'had issues with null values so added the quotes
</span>    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;Email&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;OrderDiscPercent1&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;OrderDiscPercent2&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;OrderDiscPercent3&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;Warehouse&quot;</span>, <span style="color: #800000;">&quot;&quot;</span> <span style="color: #008000;">'rst!O_Warehouse '
</span>    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;SpecialInstrs&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;SalesOrder&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;OrderType&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;MultiShipCode&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;AlternateReference&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;Salesperson&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;Branch&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;Area&quot;</span>, rst!O_Area <span style="color: #008000;">'&quot;&quot;
</span>    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;RequestedShipDate&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;InvoiceNumberEntered&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;InvoiceDateEntered&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;OrderComments&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;Nationality&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;DeliveryTerms&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;TransactionNature&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;TransportMode&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;ProcessFlag&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;TaxExemptNumber&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;TaxExemptionStatus&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;GstExemptNumber&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;GstExemptionStatus&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;CompanyTaxNumber&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;CancelReasonCode&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;DocumentFormat&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;State&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;CountyZip&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;City&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderHeaderNode.NewChild2 <span style="color: #800000;">&quot;eSignature&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    tmpHonApo = rst!O_HonAffPO
<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
    <span style="color: #000080;">Set</span> OrderDetailsStockLineNode = OrderDetailsNode.NewChild(<span style="color: #800000;">&quot;StockLine&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>)
&nbsp;
    <span style="color: #008000;">' ad criteria to define the line type in the order import
</span>    <span style="color: #008000;">'get the stock line itmes
</span>    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;CustomerPoLine&quot;</span>, tmpOrderLine
    tmpOrderLine = tmpOrderLine + 1
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;LineActionType&quot;</span>, tmpLineActionType
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;LineCancelCode&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;StockCode&quot;</span>, rst!O_Part
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;StockDescription&quot;</span>, <span style="color: #800000;">&quot;&quot;</span> <span style="color: #008000;">'Left(rst!sDescription &amp; &quot;&quot;, 30)
</span>    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;Warehouse&quot;</span>, rst!O_Warehouse  <span style="color: #008000;">'tmpDefaultWarehouse
</span>    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;CustomersPartNumber&quot;</span>, rst!O_AltPArt &amp;<span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;OrderQty&quot;</span>, rst!O_Qty
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;OrderUom&quot;</span>, rst!stockuom &amp; <span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;Price&quot;</span>, IIf(tmpLoadPrice, rst!O_Price, <span style="color: #800000;">&quot;&quot;</span>)
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;PriceUom&quot;</span>, rst!stockuom &amp; <span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;PriceCode&quot;</span>, rst!O_PriceList <span style="color: #008000;">'&quot;&quot;
</span>    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;AlwaysUsePriceEntered&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;Units&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;Pieces&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;ProductClass&quot;</span>, rst!productclass &amp; <span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;LineDiscPercent1&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;LineDiscPercent2&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;LineDiscPercent3&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;CustRequestDate&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;CommissionCode&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;LineShipDate&quot;</span>, Format(rst!O_LineShipDate, <span style="color: #800000;">&quot;yyyy-mm-dd&quot;</span>)
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;LineDiscValue&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;LineDiscValFlag&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;OverrideCalculatedDiscount&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;UserDefined&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;NonStockedLine&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;NsProductClass&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;NsUnitCost&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;UnitMass&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;UnitVolume&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;StockTaxCode&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;StockNotTaxable&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;StockFstCode&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;StockNotFstTaxable&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;ConfigPrintInv&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;ConfigPrintDel&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
    OrderDetailsStockLineNode.NewChild2 <span style="color: #800000;">&quot;ConfigPrintAck&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>
&nbsp;
    <span style="color: #008000;">'Set OrderDetailsCommentLineNode = OrderDetailsNode.NewChild(&quot;CommentLine&quot;, &quot;&quot;)
</span>    <span style="color: #008000;">'get the comment lines
</span>    <span style="color: #008000;">'OrderDetailsCommentLineNode.NewChild2 &quot;CustomerPoLine&quot;, &quot;2&quot;     'get from recordset
</span>
    <span style="color: #008000;">'Set OrderDetailsMiscChargeLineNode = OrderDetailsNode.NewChild(&quot;MiscChargeLine&quot;, &quot;&quot;)
</span>    <span style="color: #008000;">'get the Misc line details
</span>    <span style="color: #008000;">'OrderDetailsMiscChargeLineNode.NewChild2 &quot;CustomerPoLine&quot;, &quot;3&quot;     'get from recordset
</span>
    <span style="color: #008000;">'Set OrderDetailsFreightLineNode = OrderDetailsNode.NewChild(&quot;FreightLine&quot;, &quot;&quot;)
</span>    <span style="color: #008000;">'get the Freight Line Details
</span>    <span style="color: #008000;">'OrderDetailsFreightLineNode.NewChild2 &quot;CustomerPoLine&quot;, &quot;4&quot;     'get from recordset
</span>
rst.MoveNext <span style="color: #008000;">' goto the next line
</span>
<span style="color: #000080;">Loop</span>
&nbsp;
<span style="color: #008000;">'  Save the XML:
</span><span style="color: #000080;">Dim</span> success <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>
success = xml.SaveXml(<span style="color: #800000;">&quot;c:\XMLSO.xml&quot;</span>)
<span style="color: #000080;">If</span> (success &lt;&gt;1) <span style="color: #000080;">Then</span>
    MsgBox xml.LastErrorText
<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
Exit_Func:
<span style="color: #000080;">Set</span> rst = <span style="color: #000080;">Nothing</span>
<span style="color: #000080;">Set</span> HeaderNode = <span style="color: #000080;">Nothing</span>
<span style="color: #000080;">Set</span> OrderNode = <span style="color: #000080;">Nothing</span>
<span style="color: #000080;">Set</span> OrderHeaderNode = <span style="color: #000080;">Nothing</span>
<span style="color: #000080;">Set</span> OrderDetailsNode = <span style="color: #000080;">Nothing</span>
<span style="color: #000080;">Set</span> OrderDetailsStockLineNode = <span style="color: #000080;">Nothing</span>
<span style="color: #000080;">Set</span> OrderDetailsCommentLineNode = <span style="color: #000080;">Nothing</span>
<span style="color: #000080;">Set</span> OrderDetailsMiscChargeLineNode = <span style="color: #000080;">Nothing</span>
<span style="color: #000080;">Set</span> OrderDetailsFreightLineNode = <span style="color: #000080;">Nothing</span>
&nbsp;
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></div></div>

<p>The next stage is to use the file created in ExportXML() to pass to Syspro business objects.</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Function</span> OrdPost()
<span style="color: #000080;">On</span> <span style="color: #000080;">Error</span> <span style="color: #000080;">GoTo</span> Errorhandler
<span style="color: #000080;">Dim</span> XMLout, xmlIn, XMLPar
<span style="color: #000080;">Dim</span> xml <span style="color: #000080;">As</span> <span style="color: #000080;">New</span> ChilkatXml
<span style="color: #000080;">Dim</span> rec1 <span style="color: #000080;">As</span> ChilkatXml
<span style="color: #000080;">Dim</span> rec2 <span style="color: #000080;">As</span> ChilkatXml
&nbsp;
<span style="color: #000080;">Call</span> ExportXML
&nbsp;
<span style="color: #000080;">Call</span> SysproLogon
&nbsp;
<span style="color: #000080;">Dim</span> EncPost <span style="color: #000080;">As</span> <span style="color: #000080;">New</span> Encore.Transaction
XMLPar = <span style="color: #800000;">&quot;Add the xml parameters here&quot;</span>
&nbsp;
<span style="color: #008000;">'xmlIn = xml.LoadXml(&quot;c:\xmlso.xml&quot;)
</span><span style="color: #000080;">Open</span> <span style="color: #800000;">&quot;c:\xmlso.xml&quot;</span> <span style="color: #000080;">For</span> <span style="color: #000080;">Input</span> <span style="color: #000080;">As</span> #1
xmlIn = <span style="color: #000080;">Input</span>(LOF(1), 1)
<span style="color: #000080;">Close</span> #1
&nbsp;
<span style="color: #008000;">'xml.LoadXmlFile (&quot;c:\XMLSO.xml&quot;)
</span>
<span style="color: #008000;">'actually post the order
</span>XMLout = EncPost.Post(Guid, <span style="color: #800000;">&quot;SORTOI&quot;</span>, XMLPar, xmlIn)
xml.LoadXml (XMLout)
&nbsp;
xml.SaveXml (<span style="color: #800000;">&quot;c:\SORTOIOUT.xml&quot;</span>)
<span style="color: #008000;">'now see if there have been any errors
</span><span style="color: #000080;">Call</span> ReadResults
&nbsp;
<span style="color: #000080;">Exit</span> <span style="color: #000080;">Function</span>
Errorhandler:
&nbsp;
MsgBox Err.Number &amp; <span style="color: #800000;">&quot; &quot;</span> &amp; Err.Description
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></div></div>

<p>Finally you need to Read the results of the post and update the database</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Function</span> ReadResults()
&nbsp;
<span style="color: #000080;">On</span> <span style="color: #000080;">Error</span> <span style="color: #000080;">GoTo</span> Errorhandler
<span style="color: #000080;">Dim</span> XMLout, xmlIn, XMLPar
<span style="color: #000080;">Dim</span> xml <span style="color: #000080;">As</span> <span style="color: #000080;">New</span> ChilkatXml
<span style="color: #000080;">Dim</span> rec1 <span style="color: #000080;">As</span> ChilkatXml
<span style="color: #000080;">Dim</span> rec2 <span style="color: #000080;">As</span> ChilkatXml
<span style="color: #000080;">Dim</span> rec3 <span style="color: #000080;">As</span> ChilkatXml
<span style="color: #000080;">Dim</span> rec4 <span style="color: #000080;">As</span> ChilkatXml
<span style="color: #000080;">Dim</span> rec5 <span style="color: #000080;">As</span> ChilkatXml
<span style="color: #000080;">Dim</span> rst <span style="color: #000080;">As</span> Recordset, tmpReason, tmpSql
&nbsp;
<span style="color: #000080;">Dim</span> tmpMEssage1
<span style="color: #000080;">Dim</span> tmpMessage2, tmpOrder, tmpStkCode, tmpMessage(20)
<span style="color: #000080;">Dim</span> x
&nbsp;
xml.LoadXMLFile (<span style="color: #800000;">&quot;c:\SORTOIOUT.xml&quot;</span>)
<span style="color: #008000;">'search for status
</span><span style="color: #000080;">Set</span> rec4 = xml.SearchForTag(<span style="color: #000080;">Nothing</span>, <span style="color: #800000;">&quot;SalesOrder&quot;</span>)
tmpMessage(2) = rec4.Content
&nbsp;
<span style="color: #008000;">'mark order processed if we have a sales order number
</span><span style="color: #000080;">If</span> Len(tmpMessage(2) &amp; <span style="color: #800000;">&quot;&quot;</span>) &gt; 0 <span style="color: #000080;">Then</span>
    CurrentDb.Execute (<span style="color: #800000;">&quot;UPDATE tblImportData SET O_Processed = -1 WHERE  O_Number=&quot;</span> &amp; Chr(34) &amp; tmpPorder &amp; Chr(34) &amp; <span style="color: #800000;">&quot; AND O_Entity=&quot;</span> &amp; Chr(34) &amp; tmpPcountry &amp; Chr(34))
&nbsp;
<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
<span style="color: #000080;">If</span> Len(tmpMessage(2) &amp; <span style="color: #800000;">&quot;&quot;</span>) = 0 <span style="color: #000080;">Then</span>
    <span style="color: #000080;">Set</span> rec4 = xml.SearchForTag(<span style="color: #000080;">Nothing</span>, <span style="color: #800000;">&quot;Status&quot;</span>)
    tmpMessage(1) = rec4.Content
&nbsp;
    <span style="color: #008000;">'search for Errormessages
</span>    <span style="color: #000080;">Set</span> rec4 = xml.SearchForTag(<span style="color: #000080;">Nothing</span>, <span style="color: #800000;">&quot;ErrorDescription&quot;</span>)
    tmpMessage(3) = rec4.Content
&nbsp;
    <span style="color: #008000;">' Find the first article beginning with M
</span>    <span style="color: #000080;">Set</span> rec1 = xml.SearchForTag(<span style="color: #000080;">Nothing</span>, <span style="color: #800000;">&quot;Customer&quot;</span>)
    tmpMessage(4) = rec1.Content
    Debug.<span style="color: #000080;">Print</span> tmpMessage(4)
&nbsp;
    <span style="color: #000080;">Set</span> rec1 = xml.SearchForTag(<span style="color: #000080;">Nothing</span>, <span style="color: #800000;">&quot;CustomerPoNumber&quot;</span>)
&nbsp;
    tmpMessage(5) = rec1.Content
    Debug.<span style="color: #000080;">Print</span> tmpMessage(5)
&nbsp;
<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
<span style="color: #008000;">'write the overall status
</span><span style="color: #000080;">Set</span> rst = CurrentDb.OpenRecordset(<span style="color: #800000;">&quot;tblResults&quot;</span>)
<span style="color: #000080;">With</span> rst
    .AddNew
    !R_Customer = tmpPcountry
    !R_Order = tmpPorder
    !R_StockCode = <span style="color: #800000;">&quot;&quot;</span>
    !R_Error = tmpMessage(1) &amp; <span style="color: #800000;">&quot; Reason: &quot;</span> &amp; tmpMessage(3)
    !R_SYSOrder = tmpMessage(2)
    !R_MAster = <span style="color: #800000;">&quot;Y&quot;</span>
    !R_Added = Now()
    .Update
<span style="color: #000080;">End</span> <span style="color: #000080;">With</span>
<span style="color: #000080;">Set</span> rst = <span style="color: #000080;">Nothing</span>
&nbsp;
<span style="color: #000080;">Set</span> rec2 = xml.SearchForTag(rec1, <span style="color: #800000;">&quot;StockCode&quot;</span>)
&nbsp;
<span style="color: #000080;">Do</span> <span style="color: #000080;">While</span> <span style="color: #000080;">Not</span> rec2 <span style="color: #000080;">Is</span> <span style="color: #000080;">Nothing</span>
&nbsp;
    tmpMessage(6) = rec2.Content
    Debug.<span style="color: #000080;">Print</span> tmpMessage(6)
&nbsp;
    <span style="color: #000080;">Set</span> rec3 = xml.SearchForTag(rec2, <span style="color: #800000;">&quot;ErrorMessages&quot;</span>)
    <span style="color: #000080;">Do</span> <span style="color: #000080;">While</span> <span style="color: #000080;">Not</span> rec3 <span style="color: #000080;">Is</span> <span style="color: #000080;">Nothing</span>
        <span style="color: #000080;">Set</span> rec4 = rec3.SearchForTag(<span style="color: #000080;">Nothing</span>, <span style="color: #800000;">&quot;ErrorDescription&quot;</span>)
        x = 6
        <span style="color: #000080;">Do</span> <span style="color: #000080;">While</span> <span style="color: #000080;">Not</span> rec4 <span style="color: #000080;">Is</span> <span style="color: #000080;">Nothing</span>
            x = x + 1
            tmpMessage(x) = rec4.Content
            Debug.<span style="color: #000080;">Print</span> tmpMessage(x)
&nbsp;
            <span style="color: #008000;">'find the next message
</span>            <span style="color: #000080;">Set</span> rec4 = rec3.SearchForTag(rec4, <span style="color: #800000;">&quot;ErrorDescription&quot;</span>)
        <span style="color: #000080;">Loop</span>
        <span style="color: #000080;">Set</span> rec3 = rec2.SearchForTag(rec3, <span style="color: #800000;">&quot;ErrorMessages&quot;</span>)
    <span style="color: #000080;">Loop</span>
&nbsp;
    <span style="color: #008000;">'nowWrite the Results if an error occurred
</span>    <span style="color: #000080;">If</span> Len(tmpMessage(4) &amp; <span style="color: #800000;">&quot;&quot;</span>) &gt; 0 <span style="color: #000080;">Then</span>
        <span style="color: #000080;">Set</span> rst = CurrentDb.OpenRecordset(<span style="color: #800000;">&quot;tblResults&quot;</span>)
        <span style="color: #000080;">With</span> rst
        <span style="color: #000080;">Do</span> <span style="color: #000080;">While</span> x &gt;= 7
            .AddNew
            !R_Customer = tmpPcountry
            !R_Order = tmpPorder
            !R_StockCode = tmpMessage(6)
            !R_Error = tmpMessage(x)
            !R_MAster = <span style="color: #800000;">&quot;N&quot;</span>
            !R_Added = Now()
            .Update
            tmpMessage(x) = <span style="color: #800000;">&quot;&quot;</span>
            x = x - 1
        <span style="color: #000080;">Loop</span>
        <span style="color: #000080;">End</span> <span style="color: #000080;">With</span>
        <span style="color: #000080;">Set</span> rst = <span style="color: #000080;">Nothing</span>
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
<span style="color: #000080;">Set</span> rec2 = xml.SearchForTag(rec2, <span style="color: #800000;">&quot;StockCode&quot;</span>)
<span style="color: #000080;">Loop</span>
&nbsp;
<span style="color: #008000;">'now update syspro results
</span><span style="color: #000080;">Call</span> UpdateArea
&nbsp;
<span style="color: #000080;">Exit</span> <span style="color: #000080;">Function</span>
&nbsp;
Errorhandler:
&nbsp;
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://accountingsystems.ie/?feed=rss2&amp;p=8</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Downloading Customer data from Intact Business Accounting</title>
		<link>http://accountingsystems.ie/?p=5</link>
		<comments>http://accountingsystems.ie/?p=5#comments</comments>
		<pubDate>Wed, 07 Apr 2010 09:28:32 +0000</pubDate>
		<dc:creator>Patrick Jones</dc:creator>
				<category><![CDATA[Intact]]></category>

		<guid isPermaLink="false">http://accountingsystems.ie/?p=5</guid>
		<description><![CDATA[Intact Business Accounting has an SDK which is exposed for all developers and available in the system.  The following sample shows how we load the customer data into an Access database for use with our MASC Product. If you are using Intact and have any questions leave me a comment and I will reply.

&#160;
Function [...]]]></description>
			<content:encoded><![CDATA[<p>Intact Business Accounting has an SDK which is exposed for all developers and available in the system.  The following sample shows how we load the customer data into an Access database for use with our MASC Product. If you are using Intact and have any questions leave me a comment and I will reply.</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">&nbsp;
<span style="color: #000080;">Function</span> LoadCust()
<span style="color: #000080;">On</span> <span style="color: #000080;">Error</span> <span style="color: #000080;">GoTo</span> Intact_Error
<span style="color: #000080;">Dim</span> IntactTable <span style="color: #000080;">As</span> <span style="color: #000080;">New</span> INTACTSDKTable
<span style="color: #000080;">Dim</span> tmpLastRecord, r, tmpCount, tmpCompany, tmpRcode
&nbsp;
tmpRcode = GetPref(<span style="color: #800000;">&quot;RouteCode Field Name&quot;</span>)
&nbsp;
Application.Echo <span style="color: #000080;">True</span>, <span style="color: #800000;">&quot;Linking to selected Intact Company&quot;</span>
&nbsp;
tmpCompany = GetPref(<span style="color: #800000;">&quot;Intact Company&quot;</span>)
IntactTable.CompanyDirectory (tmpCompany)
IntactTable.TableName (<span style="color: #800000;">&quot;CUSTS&quot;</span>)
&nbsp;
<span style="color: #008000;">'Clear customers and set reference to table
</span>CurrentDb.Execute (<span style="color: #800000;">&quot;Delete * from tblCustomers&quot;</span>)
CurrentDb.Execute (<span style="color: #800000;">&quot;Delete * from tblCustMemo&quot;</span>)
<span style="color: #000080;">Dim</span> rstCust <span style="color: #000080;">As</span> Recordset
<span style="color: #000080;">Set</span> rstCust = CurrentDb.OpenRecordset(<span style="color: #800000;">&quot;tblCustomers&quot;</span>)
&nbsp;
r = IntactTable.First
tmpLastRecord = <span style="color: #000080;">True</span>
tmpCount = 1
&nbsp;
<span style="color: #000080;">Do</span>
    rstCust.AddNew
&nbsp;
    <span style="color: #008000;">'Assign details
</span>    rstCust!ID = IntactTable.fieldvalueasstring(<span style="color: #800000;">&quot;CODE&quot;</span>)
    Application.Echo <span style="color: #000080;">True</span>, <span style="color: #800000;">&quot;Adding Customer Seq:&quot;</span> &amp; tmpCount &amp; <span style="color: #800000;">&quot; :&quot;</span> &amp; IntactTable.fieldvalueasstring(<span style="color: #800000;">&quot;CODE&quot;</span>)
    tmpCount = tmpCount + 1
    rstCust!CustBarcode = IntactTable.fieldvalueasstring(<span style="color: #800000;">&quot;CODE&quot;</span>)
    rstCust!CompanyName = IntactTable.fieldvalueasstring(<span style="color: #800000;">&quot;NAME&quot;</span>)
    rstCust!Add1 = IntactTable.fieldvalueasstring(<span style="color: #800000;">&quot;ADR1&quot;</span>)
    rstCust!Add2 = IntactTable.fieldvalueasstring(<span style="color: #800000;">&quot;ADR2&quot;</span>)
    rstCust!Add3 = IntactTable.fieldvalueasstring(<span style="color: #800000;">&quot;ADR3&quot;</span>)
    rstCust!Town = IntactTable.fieldvalueasstring(<span style="color: #800000;">&quot;ADR4&quot;</span>)
    rstCust!County = IntactTable.fieldvalueasstring(<span style="color: #800000;">&quot;ADR5&quot;</span>)
    rstCust!Phone = IntactTable.fieldvalueasstring(<span style="color: #800000;">&quot;PHONE1&quot;</span>)    
    rstCust!CPriceCode = IIf(Len(IntactTable.fieldvalueasstring(<span style="color: #800000;">&quot;LISTCODE&quot;</span>) &amp; <span style="color: #800000;">&quot;&quot;</span>) = 0, IntactTable.fieldvalueasstring(<span style="color: #800000;">&quot;CODE&quot;</span>), IntactTable.fieldvalueasstring(<span style="color: #800000;">&quot;LISTCODE&quot;</span>))
    <span style="color: #008000;">'Check Delivery Address
</span>    <span style="color: #000080;">If</span> Len(IntactTable.fieldvalueasstring(<span style="color: #800000;">&quot;HOCODE&quot;</span>) &amp; <span style="color: #800000;">&quot;&quot;</span>) &gt; 0 <span style="color: #000080;">Then</span>
        rstCust!MasterAccount = IntactTable.fieldvalueasstring(<span style="color: #800000;">&quot;HOCODE&quot;</span>)
        rstCust!DeliveryAddress = -1
    <span style="color: #000080;">Else</span>
        rstCust!DeliveryAddress = 0
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
    rstCust!RouteCode = IntactTable.fieldvalueasstring(<span style="color: #800000;">&quot;Repcode&quot;</span>) <span style="color: #008000;">'tmpRcode) 'repcode
</span>    <span style="color: #008000;">'Frequency Check
</span>    <span style="color: #000080;">If</span> Len(IntactTable.fieldvalueasstring(<span style="color: #800000;">&quot;XXFREQ&quot;</span>) &amp; <span style="color: #800000;">&quot;&quot;</span>) &lt;&gt; 0 <span style="color: #000080;">And</span> IntactTable.fieldvalueasstring(<span style="color: #800000;">&quot;XXFREQ&quot;</span>) &lt;&gt; <span style="color: #800000;">&quot;INVALID&quot;</span> <span style="color: #000080;">Then</span>
        rstCust!Frequency = IntactTable.fieldvalueasstring(<span style="color: #800000;">&quot;XXFREQ&quot;</span>)
    <span style="color: #000080;">Else</span>
        rstCust!Frequency = <span style="color: #800000;">&quot;Docket&quot;</span>
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
    <span style="color: #008000;">'Priced Check
</span>    <span style="color: #000080;">If</span> IntactTable.fieldvalueasstring(<span style="color: #800000;">&quot;XXPRICED&quot;</span>) = <span style="color: #800000;">&quot;t&quot;</span> <span style="color: #000080;">Then</span>
        rstCust!Priced = -1
    <span style="color: #000080;">Else</span>
        rstCust!Priced = 0
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
    <span style="color: #008000;">'Active Check
</span>    <span style="color: #000080;">If</span> IntactTable.fieldvalueasstring(<span style="color: #800000;">&quot;XXACTIVE&quot;</span>) = <span style="color: #800000;">&quot;t&quot;</span> <span style="color: #000080;">Or</span> IntactTable.fieldvalueasstring(<span style="color: #800000;">&quot;XXACTIVE&quot;</span>) = <span style="color: #800000;">&quot;INVALID&quot;</span> <span style="color: #000080;">Or</span> IntactTable.fieldvalueasstring(<span style="color: #800000;">&quot;XXACTIVE&quot;</span>) = <span style="color: #800000;">&quot;&quot;</span> <span style="color: #000080;">Then</span>
        rstCust!Active = -1
    <span style="color: #000080;">Else</span>
        rstCust!Active = 0
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
    <span style="color: #000080;">If</span> IntactTable.fieldvalueasstring(<span style="color: #800000;">&quot;ForceVat&quot;</span>) = <span style="color: #800000;">&quot;T&quot;</span> <span style="color: #000080;">Then</span>
        rstCust!C_Vol1 = 1
        rstCust!C_Vol2 = IntactTable.fieldvalueasstring(<span style="color: #800000;">&quot;DefVatCode&quot;</span>)
    <span style="color: #000080;">Else</span>
        rstCust!C_Vol1 = 0
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
    <span style="color: #008000;">'Other Fields
</span>    rstCust!InvoiceMovements = -1
    rstCust!<span style="color: #000080;">Currency</span> = <span style="color: #800000;">&quot;EUR&quot;</span>
    rstCust!Orders = 0
    rstCust!MESSCHK = 0
    rstCust!CustType = <span style="color: #800000;">&quot;RET&quot;</span>
    <span style="color: #008000;">'Update record
</span>    rstCust.Update
&nbsp;
    r = IntactTable.<span style="color: #000080;">Next</span>
&nbsp;
    <span style="color: #000080;">If</span> r = -90 <span style="color: #000080;">Then</span> tmpLastRecord = <span style="color: #000080;">False</span>
&nbsp;
    <span style="color: #000080;">If</span> IntactTable.fieldvalueasstring(<span style="color: #800000;">&quot;CODE&quot;</span>) = <span style="color: #800000;">&quot;&quot;</span> <span style="color: #000080;">Then</span>
        tmpLastRecord = <span style="color: #000080;">False</span>
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
<span style="color: #000080;">Loop</span> <span style="color: #000080;">While</span> tmpLastRecord
&nbsp;
<span style="color: #000080;">Set</span> rstCust = <span style="color: #000080;">Nothing</span>
<span style="color: #000080;">Set</span> IntactTable = <span style="color: #000080;">Nothing</span>
&nbsp;
<span style="color: #000080;">Exit</span> <span style="color: #000080;">Function</span>
&nbsp;
Intact_Error:
MsgBox <span style="color: #800000;">&quot;Intact Customer List Refresh &quot;</span> &amp; Err.Number &amp; vbCrLf &amp; <span style="color: #800000;">&quot;Details &quot;</span> &amp; Err.Description &amp; vbCrLf &amp; <span style="color: #800000;">&quot;Intact Msg:&quot;</span> &amp; GetIntactMsg(Err.Number)
&nbsp;
<span style="color: #000080;">Set</span> rstCust = <span style="color: #000080;">Nothing</span>
<span style="color: #000080;">Set</span> IntactTable = <span style="color: #000080;">Nothing</span>
&nbsp;
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://accountingsystems.ie/?feed=rss2&amp;p=5</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
