<?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; Sage</title>
	<atom:link href="http://accountingsystems.ie/?feed=rss2&#038;tag=sage" 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>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>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>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>
	</channel>
</rss>
