I have a ComboBox cboDefaultVendorNo with a BeforeUpdate event that displays an error msg and sets Cancel = True if a condition exists.  If I select data from that combobox using the form, cboDefaultVendorNo_BeforeUpdate fires.  If cboDefaultVendorNo_BeforeUpdate sets Cancel = True, I cannot move off that control without fixing the data in the cbo.
	
	
	
		
If I populate that control using code instead, cboDefaultVendorNo_BeforeUpdate does not fire. But I can then run cboDefaultVendorNo_BeforeUpdate in code, which causes it to display the error.
	
	
	
		
But then it does not prevent me from moving off that control or even saving the record. Is there a way to make it so that, even if I populate the control in code, it behaves the same as if the user had populated the control using the GUI? (In other words, if the code-populated value fails validation, I'd like the GUI to disallow moving off that control or saving the record until the data is fixed or the update canceled.)
Thanks for any help you can give.
Wayne
 
		Code:
	
	
	Private Sub cboDefaultVendorNo_BeforeUpdate(Cancel As Integer)
On Error GoTo cboDefaultVendorNo_BeforeUpdateErr
    ' Validate the data
    Cancel = VendorIDBeforeUpdate(Me.cboDefaultVendorNo.Value)
cboDefaultVendorNo_BeforeUpdateBye:
    Exit Sub
cboDefaultVendorNo_BeforeUpdateErr:
    Select Case Err.Number
        Case Else
            MsgBoxErr Me.Name, "cboDefaultVendorNo_BeforeUpdate", , Me
    End Select
    Resume cboDefaultVendorNo_BeforeUpdateBye
End SubIf I populate that control using code instead, cboDefaultVendorNo_BeforeUpdate does not fire. But I can then run cboDefaultVendorNo_BeforeUpdate in code, which causes it to display the error.
		Code:
	
	
	Private Sub cboDefaultVendorNo_DblClick(Cancel As Integer)
On Error GoTo cboDefaultVendorNo_DblClickErr
    ' Populate cboDefaultVendorNo in code
    MakeFormPick Me.Parent.Name, "frmCrdVendor-Pick", "cboDefaultVendorNo", "cboDefaultVendorNo", True, "fsubChild"
    
    If Not IsNull(Me.cboDefaultVendorNo) Then
        ' Is the selected vendor valid?
        cboDefaultVendorNo_BeforeUpdate Cancel
    End If
cboDefaultVendorNo_DblClickBye:
    Exit Sub
cboDefaultVendorNo_DblClickErr:
    Select Case Err.Number
        Case Else
            MsgBoxErr Me.Name, "cboDefaultVendorNo_DblClick", , Me
    End Select
    Resume cboDefaultVendorNo_DblClickBye
End SubBut then it does not prevent me from moving off that control or even saving the record. Is there a way to make it so that, even if I populate the control in code, it behaves the same as if the user had populated the control using the GUI? (In other words, if the code-populated value fails validation, I'd like the GUI to disallow moving off that control or saving the record until the data is fixed or the update canceled.)
Thanks for any help you can give.
Wayne
 
	 
 
		 
 
		
 
 
		 
 
		 
 
		 
 
		