Yes Tom, I think you are right The Invoice is already saved so it just keeps
changing the [fraSelectInvoiceNoType ] Because this is part of
SubSetInvoiceValues
Sub subSetValues()
Dim recOwnersInfo As New ADODB.Recordset
Dim dblTotal As Double
Dim dblOwnerPercentAmount As Double
Dim recTmpOwner As New ADODB.Recordset
recTmpOwner.Open "SELECT CompanyID FROM tblCompanyInfo WHERE CompanyName
LIKE '" _
& tbCompanyName.value & "'", CurrentProject.Connection, adOpenDynamic,
adLockOptimistic
recOwnersInf
pen "Select * from tblOwnerInfo where OwnerID=" &
cbOwnerName.Column(0), _
CurrentProject.Connection, adOpenDynamic, adLockOptimistic
With recInvoice
.Fields("CompanyID") = Nz(recTmpOwner.Fields("CompanyID"), 0)
.Fields("InvoiceID") = tbInvoiceID.value
.Fields("ClientInvoice") = True
.Fields("HorseID") = 0
.Fields("HorseName") = ""
.Fields("FatherName") = tbFatherName.value
.Fields("MotherName") = tbMotherName.value
.Fields("ClientDetail") = tbClientDetail.value
If tbDateOfBirth.value = "" Or IsNull(tbDateOfBirth.value) Then
Else
.Fields("DateOfBirth") = Format(CDate(tbDateOfBirth.value),
"mm/dd/yyyy")
.Fields("HorseDetailInfo") = tbFatherName.value & "--" &
tbMotherName.value & "--" & funCalcAge(Format(tbDateOfBirth.value,
"dd-mmm-yyyy"), Format("01-Aug-" & Year(Now()), "dd-mmm-yyyy"), 1) & "-" &
tbSex.value
End If
.Fields("Sex") = tbSex.value
.Fields("GSTOptionsText") = cbGSTOptions.value
.Fields("GSTOptionsValue") = IIf(tbGSTOptionsValue = "" Or
IsNull(tbGSTOptionsValue), 0, tbGSTOptionsValue)
.Fields("SubTotal") = IIf(tbSubTotal = "" Or IsNull(tbSubTotal), 0,
tbSubTotal)
.Fields("TotalAmount") = IIf(tbTotalAmount = "" Or
IsNull(tbTotalAmount), 0, tbTotalAmount)
'************This was original code that keeped adding Invoice
number each time you opened the form*******
If fraSelectInvoiceNoType = 1 Then
recInvoice.Fields("InvoiceNo") = NextInvoiceNo
ElseIf fraSelectInvoiceNoType = 2 Then
recInvoice.Fields("InvoiceNo") = 0
End If
'************************************************************************************
If tbInvoiceDate.value = "" Or IsNull(tbInvoiceDate.value) Then
Else
.Fields("InvoiceDate") = Format(CDate(tbInvoiceDate.value),
"dd/mm/yyyy")
End If
If recOwnersInfo.EOF = True And recOwnersInfo.BOF = True Then
Else
.Fields("OwnerID") = recOwnersInfo.Fields("OwnerID")
.Fields("OwnerName") =
IIf(IsNull(recOwnersInfo.Fields("OwnerTitle")), "",
recOwnersInfo.Fields("OwnerTitle") & " ") _
& IIf(IsNull(recOwnersInfo.Fields("OwnerFirstName")), "",
recOwnersInfo.Fields("OwnerFirstName") & " ") _
& IIf(IsNull(recOwnersInfo.Fields("OwnerLastName")), "",
recOwnersInfo.Fields("OwnerLastName") & " ")
.Fields("OwnerAddress") = recOwnersInfo.Fields("OwnerAddress")
End If
dblTotal = IIf(tbTotalAmount.value = "" Or
IsNull(tbTotalAmount.value), 0, val(tbTotalAmount.value))
dblOwnerPercentAmount = dblTotal
.Fields("OwnerPercentAmount") = dblOwnerPercentAmount
.Fields("OwnerPercent") = 1
dblGSTContentsValue = (dblOwnerPercentAmount / 9)
.Fields("GSTContentsValue") = dblGSTContentsValue
If dblGSTContentsValue > 0 Then
.Fields("GSTContentsText") = "Tax Contents"
ElseIf dblGSTContentsValue < 0 Then
.Fields("GSTContentsText") = "Credit"
Else
.Fields("GSTContentsText") = ""
End If
End With
End Sub