I am building a form to insert data into a table using an insert statement behind a command button. The user selects a customer from a combo box, and then enters other data into the form. The combo box value is one of the fields being inserted via the insert statement.
I am trying to prevent the user from changing the customer until the command button's insert statement has been run.
Here's my latest attempt, which causes a run-time error 2115:
I have tried this (or similar code) on Click, on Got Focus, on After Update, and nothing works, the msgbox pops up but the customer changes to the new selection.
I have tried me.cboCustomer.undo with no success.
I have also tried to capture the previous customer and then set it back, but I can't figure out how or when to capture the previous customer.
Any help would be appreciated!
Thanks,
Sup
I am trying to prevent the user from changing the customer until the command button's insert statement has been run.
Here's my latest attempt, which causes a run-time error 2115:
Code:
Private Sub cboCustomer_BeforeUpdate(Cancel As Integer)
Dim rst As Recordset
Set rst = CurrentDb.OpenRecordset("tblPrepayTmp")
If rst.RecordCount > 0 Then
MsgBox "You have not posted the previous customer's payment." & vbCrLf & "Please click 'Post payment' or 'Reset entry' before choosing a new customer.", vbInformation, "Unposted entries"
Me.cboCustomer.Value = Me.cboCustomer.OldValue
Exit Sub
End If
Call fncReset
End Sub
I have tried this (or similar code) on Click, on Got Focus, on After Update, and nothing works, the msgbox pops up but the customer changes to the new selection.
I have tried me.cboCustomer.undo with no success.
I have also tried to capture the previous customer and then set it back, but I can't figure out how or when to capture the previous customer.
Any help would be appreciated!
Thanks,
Sup