I an an intermediate programmer working on updating a database for our company that someone else has written. i have struggled with this for a week and cannot find any information anywhere on the internet so humbly I ask for you programming experts.
Here is the existing code that works great and will print 1 check based on 1 Payee and 1 Loan Amount:
'Add new record to tblChecks
Dim rstChecks As Recordset
Set rstChecks = dbs.OpenRecordset("tblChecks", dbOpenDynaset)
With rstChecks
.AddNew
!CheckNo = (DLookup("MaxofCheckNo", "qryLastCheck")) + 1
!Payee = [Forms]![frmLoanEntry]![Name]
!Amount = -[Forms]![frmLoanEntry]![Amount]
!Reason = DMax("[LoanNo]", "tblLoans", "[CustomerID] = " & Forms!frmcustomerentry!CustomerID)
!TransType = "CHECK"
.Update
End With
Now I have added a toggle button to this form called [TsplitValue] which will open up two more fields named [SplitCheckPayee] and [SplitCheckAmount] so that I can print more than one check if needed
I want one of three things to happen based on certain criteria
1. IIF [TSplitValue] is false then the original code above will fire and recorded in tblChecks (Prints 1 Check)
2. IIF [TsplitValue] is true AND [SplitCheckAmount] = [Amount] then a [SplitcheckPayee] using [SplitCheckAmount] will be recorded in tblChecks(Prints 1 Check)
3. IIF [TsplitValue] is true and [SplitCheckAmount] < [Amount] then [Name] will get a check for [amount]-[splitcheckamount] and get recorded in tblchecks AND [SplitCheckPayee] will get a check for [SplitcheckAmount] and recorded in tblChecks(Prints 2 Checks)
The checks all get recorded later and that part of the code is fine. I have tried coding this 9 ways to Sunday but I cannot figure out how to conditionally format a recordset. Please any help would be great!
I tried this and tested but it will not work whatsoever so I realize that I am on the wrong path! Help me please Access Geniuses!
Dim rstChecks As Recordset
Set rstChecks = dbs.OpenRecordset("tblChecks", dbOpenDynaset)
With rstChecks 'Prints One check to Payee
If [TSplitcheck] = False Then
.AddNew
!CheckNo = (DLookup("MaxofCheckNo", "qryLastCheck")) + 1
!Payee = [Forms]![frmLoanEntry]![Name]
!Amount = -[Forms]![frmLoanEntry]![Amount]
!Reason = DMax("[LoanNo]", "tblLoans", "[CustomerID] = " & Forms!frmcustomerentry!CustomerID)
!TransType = "Check"
.Update
Else
If (-[Forms]![frmLoanEntry]![Amount]) = (-[Forms]![frmLoanEntry]![SplitCheckAmount]) Then
'Prints One check to Split Check Payee
.AddNew
!CheckNo = (DLookup("MaxofCheckNo", "qryLastCheck")) + 1
!Payee = [SplitCheckPayee]
!Amount = [SplitCheckAmount]
!Reason = DMax("[LoanNo]", "tblLoans", "[CustomerID] = " & Forms!frmcustomerentry!CustomerID)
!TransType = "CHECK"
.Update
End With
End If