Results 1 to 9 of 9
  1. #1
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402

    Issue with form when opening in AcDialog Mode I Think!!

    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

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    I think it would be better to put this validation code in the forms Before Update event but I can't say that it will definitely solve your problem.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi Bob

    Tried that but unfortunately it did not resolve the issue

    Steve

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Can you post a copy in A2003 mdb format.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    I Have attached a sample of the database, i cant save it as MBD, Can only save it in 2010 format, sorry

    hope this helps

    steve
    Attached Files Attached Files

  6. #6
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Sorry Bob

    I cant save the Database as MDB as i'm told that "You Cannot Save this Version in an earlier Version Format because it uses features that require the current file format"

    Steve

  7. #7
    SteveH2508 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2010
    Location
    Chelsea, London, England
    Posts
    116
    Your DoCmd.Close is never run when there is missing data because you have a load of End statements. The End statement halts all VBA code right there. You might want to use Exit Sub to get out before your close command.

  8. #8
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi Steve

    thanks for the heads up Do I replace all the end if's with exit sub ?

    steve

  9. #9
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi Steve

    I drop my hat to you mate, i replaced the End with Exit Sub and it working

    Many Thanks

    Steve D

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 9
    Last Post: 10-17-2012, 11:37 AM
  2. Replies: 1
    Last Post: 08-09-2012, 08:56 PM
  3. Combo box requery issue in tabbed form mode
    By michael0610 in forum Access
    Replies: 9
    Last Post: 11-17-2011, 03:22 PM
  4. Opening Saved data in form in Edit mode
    By l3111 in forum Forms
    Replies: 7
    Last Post: 06-06-2011, 11:37 AM
  5. Opening Form in Data Entry Mode Problem
    By alsoto in forum Forms
    Replies: 1
    Last Post: 05-28-2009, 07:45 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums