Public TotalClaim

Sub AddClaimRec()
Dim rs As New ADODB.Recordset
OpenDB
' rs.Close
k = 3
rs.Open "select * from ClaimTable WHERE ID =1", cn, adOpenKeyset, adLockOptimistic
ThisClaimPartner = frmMaster.ClaimPartner.Value

TotalClaim = 0
For idx = 1 To FC
If Len(FileData(idx, 5)) > 0 Then TotalClaim = TotalClaim + CDec(FileData(idx, 5))
Next idx
CDF_ID = FileData(1, 0)
DFG = FileData
rs.AddNew
rs!CDF_ID = CDF_ID
rs!ClaimStatus = "Awaiting Claim Approval"
rs!Partner_Name = ThisClaimPartner
rs!ClaimType = ClaimType
rs!ClaimValue = TotalClaim
rs!RAM = ThisRAM
rs!LastActivityMonth = CStr(Format(Date, "mmm-yy"))
rs!ClaimedBy = ThisUser
rs!ClaimDate = Date

'P1Q416/JB/1630
rs!Quarter = "20" & Mid(CDF_ID, 5, 2) & "-" & Mid(CDF_ID, 3, 2)
rs.Update




rs.Close

Set rs = Nothing
CloseDB



End Sub

Sub AddDocs()
Dim imgByte() As Byte
Dim fso As New Scripting.FileSystemObject
OpenDB

strSQL = "Select Max(ID) FROM ClaimTable"
Set rs = cn.Execute(strSQL)
ClaimRef = rs.Fields(0)
rs.Close
rs.Open "select * from ClaimDocs WHERE ID =1", cn, adOpenKeyset, adLockOptimistic



For idx = 1 To FC 'FC count of claim docs

rs.AddNew
rs!CDF_ID = FileData(idx, 0)
rs!OriginalName = Left(FileData(idx, 3), 50)

'create file name as P1Q316-SYN-1438 Inv 1 c23.pdf
Oldname = FileData(idx, 3)
NN = Len(Oldname) - InStrRev(Oldname, ".") + 1
FileType = Right(Oldname, NN)

rs!DocuType = FileData(idx, 1)
rs!ClaimID = ClaimRef
If FileData(idx, 1) = "Invoice" Then
rs!PartnerInvNo = FileData(idx, 4)
rs!InvAmt = FileData(idx, 5)
End If
rs!DateAdded = Date

OName = Replace(FileData(idx, 0), "/", "-") & " " & Left(FileData(idx, 1), 3) & idx & " c" & ClaimRef & " " & FileType



'get the file and copy to server
FileFullName = FileData(idx, 2)
' SubFold = "FY" & Mid(CDF_ID, 5, 2) & "\"
' SupName = SupName & Suffx
SubFold = "\CDF_Documents\" & OName

Newfname = SR & SubFold
fso.CopyFile FileFullName, Newfname
rs!DocName = OName
rs!DocName = SubFold
rs.Update
Next idx

End Sub