BlueSpruce
Well-known member
- Local time
- Yesterday, 23:22
- Joined
- Jul 18, 2025
- Messages
- 1,214
I have a customer form that won't enable a button for opening a popup modal form for adding related contracts unless a customer is selected, and the customer's status is normal.
In the customer form's On Current event, I have the following code that locks the Add Contract button if the customer status is not Normal, yet users have been adding new contracts despite the status not being normal. The Add Contract modal form cannot be opened by itself, so I am baffled as to how users have been adding contracts for deceased customers.
In the customer form's On Current event, I have the following code that locks the Add Contract button if the customer status is not Normal, yet users have been adding new contracts despite the status not being normal. The Add Contract modal form cannot be opened by itself, so I am baffled as to how users have been adding contracts for deceased customers.
Code:
Private Sub Form_Current()
On Error GoTo locErrorHandler
cmdSave.Transparent = True
cmdUndo.Transparent = True
'4/17/2024 Efrain: Checks to see if customer has normal status. If not then makes ribbon red and disables new contract button
Dim lngRed As Long, lngGreen As Long
lngRed = RGB(255, 0, 0)
lngGreen = RGB(35, 183, 77)
If Me.cboCustomerStatusID = 1 Then 'Normal Status
Me.txtDisplayCustomer.BackColor = lngGreen
Me.txtDisplayStatus.BackColor = lngGreen
Me.cmdNewContract.Enabled = True
DoCmd.GoToControl cmdNewContract.Name
Else 'everything else
Me.txtDisplayCustomer.BackColor = lngRed
Me.txtDisplayStatus.BackColor = lngRed
Me.cmdNewContract.Enabled = False
DoCmd.GoToControl cmdClose.Name
End If
locExitHere:
Exit Sub
locErrorHandler:
ErrorHandler Me.Name, "frmCustomer, On Current Event"
If gErrorResponse = 1 Then Resume
If gErrorResponse = 2 Then Resume Next
Resume locExitHere
End Sub