Hi there, I have an existing thread Here. Unfortunately, I have not gone beyond my last post, and my problem seemed to have spilled over to some vba scripting which I'm totally at a lost.
To make it short, I have a mainform and a subform. I have a DLookup function in my subform.combobox that is based on the mainform.combobox text value.
What I would like to do is similar to the northwind purchase order form. Which basically has a "feature" that if a user has chosen a Supplier and have chosen items to be ordered, then suddenly the user tries to change the Supplier, a warning will pop-up,

Basically telling the user that if you continue, all the items that has been ordered for that particular purchase order will be deleted unless the user presses the "No" option, thus cancelling the combobox update.
I found the before update event procedure for the SupplierID combobox here:
I tried to figure it out, but I do not know how to even start, like where do I find the ChangeSupplierWarning indicated in the MsgBoxYesNo(), usually it is the text that is displayed on the message box, but I can't find it. If there is someone here who could shed some light to this, probably if it is not too much to ask, explain what is happening on each part of the procedure, it would greatly help me understand.
Thanks!
To make it short, I have a mainform and a subform. I have a DLookup function in my subform.combobox that is based on the mainform.combobox text value.
What I would like to do is similar to the northwind purchase order form. Which basically has a "feature" that if a user has chosen a Supplier and have chosen items to be ordered, then suddenly the user tries to change the Supplier, a warning will pop-up,

Basically telling the user that if you continue, all the items that has been ordered for that particular purchase order will be deleted unless the user presses the "No" option, thus cancelling the combobox update.
I found the before update event procedure for the SupplierID combobox here:
PHP:
Public Function GetPurchaseDetailsSubform() As [Form_Purchases Subform for Purchase Order Details]
Set GetPurchaseDetailsSubform = Me.sbfPurchaseDetails.Form
End Function
Private Function PurchaseContainsLineItems() As Boolean
PurchaseContainsLineItems = Me.GetPurchaseDetailsSubform.RecordsetClone.RecordCount > 0
End Function
Private Sub Supplier_ID_AfterUpdate()
Me.GetPurchaseDetailsSubform.Product_ID.Requery
Me.[Purchase Details_Page].Enabled = True
End Sub
Private Sub Supplier_ID_BeforeUpdate(Cancel As Integer)
'Changing Suppliers with defined line items requires some decisions
If PurchaseContainsLineItems() Then
If Not MsgBoxYesNo(ChangeSupplierWarning) Then
Cancel = True
ElseIf PurchaseOrder_ContainsPostedInventory() Then
MsgBoxOKOnly CannotRemovePostedItems
Cancel = True
ElseIf Not FRemovePurchaseLineItems() Then
MsgBoxOKOnly ErrorRemovingPurchaseLineItems
Cancel = True
End If
End If
End Sub
I tried to figure it out, but I do not know how to even start, like where do I find the ChangeSupplierWarning indicated in the MsgBoxYesNo(), usually it is the text that is displayed on the message box, but I can't find it. If there is someone here who could shed some light to this, probably if it is not too much to ask, explain what is happening on each part of the procedure, it would greatly help me understand.
Thanks!