Hi All
I have a problem with a form that has been troubling me for the last few days and I just can't seam to find answer.
I have a form called "Add Order" that records detailed information about an order, this has a sub form called "Orders Details" that holds details of the order such as
Supplier Name,ProductName, Description, Sales Price, Cost Price and Product Code.
ProductName on the "Orders Details" Form is a combo box and i have managed to create a "Not in List" event that opens up a form called "Add Product from Order Form" if the product you entered in the ProductName Combo box is not already present.
When the "Add product From Order Form" opens it's ProductName is filled out automatically from the name entered in the combo box on the Add Orders Form.
The issue I can't seam to find a resolution for is this.
I have this VBA code running behind the close button of the "Add Product From Order Form"
Private Sub Close_Add_Product_Form_Click()
Dim SupplierMSG As Integer
Dim ProductnameMSG As Integer
Dim DescriptionMSG As Integer
If (IsNull([Supplier])) Then
Beep
SupplierMSG = MsgBox("You Must Enter The Supplier Of This Product", vbOKOnly, "")
DoCmd.GoToControl "SupplierID"
End
ElseIf (IsNull([ProductName])) Then
Beep
ProductnameMSG = MsgBox("You Must Enter The Name Of This Product", vbOKOnly, "")
DoCmd.GoToControl "ProductName"
End
ElseIf (IsNull([Description])) Then
Beep
DescriptionMSG = MsgBox("You Must Enter A Description For This Product", vbOKOnly, "")
DoCmd.GoToControl "Description"
End
End If
'rules for the message boxes for the Purchase and Sales Price items, if no
'value is entered a pop up box will open asking if this is ok
Dim PurchasePriceMSG As Integer
'display message box on screen, with YES and NO buttons
If Me.Cost_Price = 0 Then
PurchasePriceMSG = MsgBox("Do You Want To Add A Purchase Price Amount?", vbQuestion + vbYesNo + vbDefaultButton2, "Continue?")
'If you click yes, you are returned to the purchase price to enter a value
If PurchasePriceMSG = vbYes Then
DoCmd.GoToControl "Cost Price"
End
'if you click no, you move on the the sales price
End If
End If
Dim SalesPriceMSG As Integer
'display message box on screen, with YES and NO buttons
If Me.List_Price = 0 Then
SalesPriceMSG = MsgBox("Do You Want To Add A Sales Price Amount?", vbQuestion + vbYesNo + vbDefaultButton2, "Continue?")
'If you click yes, you are returned to the Sales price to enter a vale
If SalesPriceMSG = vbYes Then
DoCmd.GoToControl "List Price"
End
' if you click no the form will close
End If
End If
DoCmd.Close
End Sub
The form works as it should if you fill out all the items, but if you miss some such as "Description" the message box appears telling you that the "Description" is required, but the close button never closes the form when the Relevant text areas have been filled out also the form can't be closed even if all the text areas are filled out. if you put the form into design mode then back into form view the close button works??
The "Add Product From Order Form" works as expected if you open it up directly the validation works, the message box appears, and the close button works when pressed after the missing information has been filled out.
This form is opened up in ACDialog mode from the "Not in list event" that's fired from the "Orders Details" form "ProductName".
If I change ACDialog to ACNormal, the combo-box on the "Orders Details" form keeps telling me that "The Text You Entered is Not An Item In The List" and the close button VBA on the "Add Product From Order Form" works but the new part in not available.
I'm sorry for the really long post but, any help would be absolutely fantastic.
I'm Running Access 2010 32Bit