BlueSpruce
Active member
- Local time
- Today, 13:35
- Joined
- Jul 18, 2025
- Messages
- 230
1. I have users who periodically view a datasheet subform on the main dashboard that displays past due contracts.
2. Users drill down to certain contracts and decide if they want to forfeit the contract, or skip it and move on to the next contract. In the example below, the user decided to forfeit contract 36410:
3. When the forfeit transaction is committed and the transaction popup closes, the popup's on close event fires the following code, requerying the forfeited, active counts, and amounts in the customer form.
4. So when users close the contract form they just updated, it also closes the customer form and control returns to the past due contracts datasheet so users can continue where they left off and select the next contract they want to drill down and possibly forfeit. Contract 36410 that was just forfeited no longer appears on the past due datasheet. I thought by bookmarking each contract users drill down to and tracking the next contract in the recordset would highlight the next contract on the list if users forfeit current contract. However, it didn't work and the record selector resets back to the first record after the datasheet is requeried. I then tried using CurrentRecord, incrementing/decrementing the record cursor, and DoCmd.RunCommand acCmdSelectRecord _ Me!RowHighlight = Me!RefContractNo in On Current event, as seen in the func below, but no success
2. Users drill down to certain contracts and decide if they want to forfeit the contract, or skip it and move on to the next contract. In the example below, the user decided to forfeit contract 36410:
3. When the forfeit transaction is committed and the transaction popup closes, the popup's on close event fires the following code, requerying the forfeited, active counts, and amounts in the customer form.
Code:
Private Sub Form_Close()
If CurrentProject.AllForms("frmCustomer").IsLoaded Then
Forms!frmCustomer.frmCustomer_subContractsDetailsList.Requery
Forms!frmCustomer!txtTotActive.Requery
Forms!frmCustomer!txtTotRedeemedAmount.Requery
Forms!frmCustomer!txtTotRedeemed.Requery
Forms!frmCustomer!txtTotForfeited.Requery
End If
If CurrentProject.AllForms("frmFindCustomer").IsLoaded Then
Forms!frmFindCustomer!LastContractNo.Requery
Forms!frmFindCustomer!LastAmount.Requery
Forms!frmFindCustomer!LastDateTime.Requery
Forms!frmFindCustomer!txtContractNoFrom.Requery
Forms!frmFindCustomer!txtBirthDateFrom.Requery
Forms!frmFindCustomer!txtTransactionDate.Requery
Forms!frmFindCustomer!TotNotPrinted.Requery
Forms!frmFindCustomer!TotNotPrintedAmount.Requery
Forms!frmFindCustomer!TotActive.Requery
Forms!frmFindCustomer!TotActiveAmount.Requery
Forms!frmFindCustomer!TotOverdue.Requery
Forms!frmFindCustomer!TotOverdueAmount.Requery
Forms!frmFindCustomer!TotRedeem.Requery
Forms!frmFindCustomer!TotRedeemAmount.Requery
Forms!frmFindCustomer!TotForfeited.Requery
Forms!frmFindCustomer!TotForfeitedAmount.Requery
Forms!frmFindCustomer!subDisplay.Requery
Select Case Forms!frmFindCustomer!LastButtonPressed
Case "NP"
Forms!frmFindCustomer!TotalContractsByType = Forms!frmFindCustomer!TotNotPrinted
Forms!frmFindCustomer!TotalAmountByType = Forms!frmFindCustomer!TotNotPrintedAmount
Forms!frmFindCustomer!TotalContractsByType.ForeColor = vbRed
Case "Active"
Forms!frmFindCustomer!TotalContractsByType = Forms!frmFindCustomer!TotActive
Forms!frmFindCustomer!TotalAmountByType = Forms!frmFindCustomer!TotActiveAmount
Forms!frmFindCustomer!TotalContractsByType.ForeColor = vbRed
Case "Overdue"
Forms!frmFindCustomer!TotalContractsByType = Forms!frmFindCustomer!TotOverdue
Forms!frmFindCustomer!TotalAmountByType = Forms!frmFindCustomer!TotOverdueAmount
Forms!frmFindCustomer!TotalContractsByType.ForeColor = vbRed
Case "redeem"
Forms!frmFindCustomer!TotalContractsByType = Forms!frmFindCustomer!TotRedeem
Forms!frmFindCustomer!TotalAmountByType = Forms!frmFindCustomer!TotRedeemAmount
Forms!frmFindCustomer!TotalContractsByType.ForeColor = vbWhite
Case "forfeit"
Forms!frmFindCustomer!TotalContractsByType = Forms!frmFindCustomer!TotForfeited
Forms!frmFindCustomer!TotalAmountByType = Forms!frmFindCustomer!TotForfeitedAmount
Forms!frmFindCustomer!TotalContractsByType.ForeColor = vbWhite
Case "transdate"
Forms!frmFindCustomer!TotalContractsByType = DCount("transactionamount", "qryDashboardTotalsTraansactions", "TransDate = #" & Forms!frmFindCustomer!txtTransactionDate & "#")
Forms!frmFindCustomer!TotalAmountByType = DSum("transactionamount", "qryDashboardTotalsTraansactions", "TransDate = #" & Forms!frmFindCustomer!txtTransactionDate & "#")
Forms!frmFindCustomer!TotalContractsByType.ForeColor = vbWhite
End Select
End If
4. So when users close the contract form they just updated, it also closes the customer form and control returns to the past due contracts datasheet so users can continue where they left off and select the next contract they want to drill down and possibly forfeit. Contract 36410 that was just forfeited no longer appears on the past due datasheet. I thought by bookmarking each contract users drill down to and tracking the next contract in the recordset would highlight the next contract on the list if users forfeit current contract. However, it didn't work and the record selector resets back to the first record after the datasheet is requeried. I then tried using CurrentRecord, incrementing/decrementing the record cursor, and DoCmd.RunCommand acCmdSelectRecord _ Me!RowHighlight = Me!RefContractNo in On Current event, as seen in the func below, but no success

Code:
Option Compare Database
Option Explicit
Private Function DisplayContract()
If Me.CurrentRecord = 1 Then
crId = Me.CurrentRecord
'First record
ElseIf Me.CurrentRecord = Me.RecordsetClone.RecordCount Then
'Last record
crId = Me.CurrentRecord - 2
Else
'not first or last
crId = Me.CurrentRecord - 1
End If
Dim intContractNo As Variant
Dim intCustID As Integer
intContractNo = Me.ContractNo
intCustID = Me.CustomerSIID
DoCmd.OpenForm "frmCustomer"
With Forms!frmCustomer
!txtPrimaryKey = intCustID
.Requery
End With
gReturnToFormName = "frmCustomer"
DoCmd.OpenForm "frmContract", WindowMode:=acDialog, OpenArgs:=intContractNo
End Function
Private Function CheckForEnterKey(KeyCode As Integer)
If KeyCode = vbKeyReturn Then
DisplayContract
End If
End Function
Private Sub Form_Current()
DoCmd.RunCommand acCmdSelectRecord
Me!RowHighlight = Me!RefContractNo
End Sub
Private Sub Form_Load()
' Call CreateRightClickMenu
Application.CommandBars("Form Datasheet Subcolumn").Enabled = True
DoCmd.RunCommand acCmdSelectRecord
End Sub
Private Sub ContractNo_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
DisplayContract
End If
End Sub
Private Sub ContractStatus_KeyDown(KeyCode As Integer, Shift As Integer)
CheckForEnterKey KeyCode
End Sub
Private Sub DaysInterestDue_KeyDown(KeyCode As Integer, Shift As Integer)
CheckForEnterKey KeyCode
End Sub
Private Sub DisplayComment_Click()
'SendKeys "{F2}"
' DoCmd.RunCommand acCmdZoomBox
DoCmd.OpenForm "frmPopUpDisplayContractComments", , , "Contractno = " & Me.ContractNo & ""
End Sub
Private Sub txtContractNo_KeyDown(KeyCode As Integer, Shift As Integer)
CheckForEnterKey KeyCode
End Sub
Private Sub txtReedemedAmount_KeyDown(KeyCode As Integer, Shift As Integer)
CheckForEnterKey KeyCode
End Sub
Attachments
Last edited: