At last i managed to solve the problem , first i downloaded the onscript
http://www.computerperformance.co.uk...e/onscript.htm
and i removed those last three lines
Option Explicit
Function UpdateCOA(AccDimCode,Name,manager,closed,category, Rep1,Rep2,Rep3,Rep4,Rep5,RepLevel,AllocNum,AutoAcc ,AccrualAcc,AccrualYear,AccrualPer,UsrGrp,cc,db)
'Function to get EAN code from Stock Item and replace that stock code with the EAN
' Function to get EAN code from Stock Item and replace that stock code with the EAN
Dim dsn 'As String
Dim cn 'As ADODB.Connection
Dim sqlStmt 'As String
Dim recData 'As ADODB.Recordset
Dim accountExists 'As Integer 'not sure what this is for
Dim TmpSupplier 'As String
dsn = "Provider=SQLOLEDB;Trusted_Connection=yes; Data Source=" & db & "; Initial Catalog=ScaSystemDB;" &_
" user id='user'; password='pwd'"
set cn = CreateObject("ADODB.connection")
cn.open dsn
'Check if connection is open
MsgBox cn.State, vbOkOnly, "cn 1"
sqlStmt = "select DBName from ScaCompanies where CompanyCode = '" & cc & "'"
'Check sqlStmt
MsgBox sqlStmt, vbOkOnly, "sqlStmt 1"
Set recData = CreateObject("ADODB.Recordset")
recData.open sqlStmt, cn
if not recData.EOF then databaseName = recData(0)
recData.close
cn.close
dsn = "Provider=SQLOLEDB;Trusted_Connection=yes; Data Source=" & db & "; Initial Catalog=" &_
databaseName & "; user id='user'; password='pwd'"
set cn = createObject("ADODB.connection")
cn.open dsn
'Check if connection is open
MsgBox cn.State, vbOkOnly, "cn 1"
'Check for OVT code
accountexists = 0
'Set recData = CreateObject("ADODB.Recordset")
sqlStmt = "Update GL03" & cc & "06 Set GL03003 = '" & Name & "' , GL03006 = '" & manager & "' , GL03007 = '" & closed & "', GL03008 = '" & category &_
"', GL03009 = '" & Rep1 & "' , GL03010 = '" & Rep2 & "', GL03011 = '" & Rep3 & "', GL03012 = '" & Rep4 & "', GL03013 = '" & Rep5 &_
"' , GL03014 = '" & RepLevel & "', GL03015 = '" & AllocNum & "' , GL03016 = '" & AutoCc &_
" ', GL03017 = '" & AccrualAcc & "', GL03018 = '" & AccrualYear & "', GL03019 = '" & AccrualPer & "',GL03020 = '" & UsrGrp & "' WHERE GL03001 = '" & AccDimCode & "'"
'Check sqlStmt
MsgBox sqlStmt, vbOkOnly, "sqlStmt 2"
recData.open sqlStmt, cn
' if not recData.EOF then
' if Len(recData(0)) > 0 then
' TmpSupplier = recData(0)
' else
' TmpSupplier = supplier
' end if
' end if
recData.Close
cn.close
UpdateCOA = sqlStmt
End Function
Call UpdateCOA( <insert values here>)
Thanks alot for your effort and pateince Joe , Thanks sam , thanks to every one who gave me support , i do really appreciate it