Results 1 to 10 of 10
  1. #1
    CHEECO is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    156

    Security level 2012 cannot find the referenced form "Multiply Dialog"






    I am using, (Security Levels 2012b) by Liam Sullivan and when ever I hit the Cancel button or hit the "X" top right corner of form "Multiply Dialog" I get a message box that says "Security level 2012 cannot find the referenced form "Multiply Dialog"". The form is spelled correctly. I am using Ms Access 2016.

    The below is the code for the "Multiply Dialog" form. Thank-you
    Cheeco

    [CODE]
    Option Compare Database
    Option Explicit

    Private Sub OK_Click()
    Me.Visible = False
    End Sub

    Private Sub Cancel_Click()
    DoCmd.CloseacForm, "Multiply Dialog"
    End Sub
    [/CODE]




  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    CODE tags did not work. How did the end tag get mixed font?

    I don't understand the code. Why are users allowed to make form not visible? What purpose does this serve? How is form made visible so they can access the Cancel button? How does clicking X close run code to close "Multiply Dialog". I normally disable X close when I code buttons to call the close action.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    CHEECO is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    156
    I am not sure what your are talking about so I have attached a copy of the data base.

    Just right click and close the login form and open the "Multiply Dialog" form and click the cancel button.
    Attached Files Attached Files

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Click Cancel button or X close - form closes. No error.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    CHEECO is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    156
    That is wiered. Iam running office 2016 32 bit. Tried on both my laptops and I get the error win win 8.1 32bit and win 10 64 bit.. I am going to try office 64 bit.

  6. #6
    CHEECO is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    156
    I just realized that if you open the "Multiply Dialog" form directly there is no error just as you said. But if you open the recipe form then click on the "Multiply" button, that open the "Multiply Dialog" form and then if you click the "X" or "Cancel the error pops up.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    The code in Recipes is referencing controls on Multiply Dialog but the form has already been closed. Try:

    Code:
        If CurrentProject.AllForms("Multiply Dialog").IsLoaded Then
            If IsNull(Forms![Multiply Dialog]![Factor]) Or Forms![Multiply Dialog]![Factor] = 0 Then
                DoCmd.Close acForm, "Multiply Dialog"
                Exit Sub
            Else
                DoCmd.Hourglass True
                dblFactor = CDbl(Forms![Multiply Dialog]![Factor])
                Set rst = Me![Recipes Subform].Form.RecordsetClone
                rst.MoveFirst
                While (Not (rst.EOF))
                    rst.Edit
                    rst![Quantity] = rst![Quantity] * dblFactor
                    rst.Update
                    rst.MoveNext
                Wend
                Me.SetFocus
                Me![NumberofServings] = Forms![RECIPES]![NumberofServings] * dblFactor
                rst.Close
            End If
        End If
    However, for such a simple input and because the Multiply Dialog does not have any significant code, I would probably just use an InputBox instead of the form, like:
    Code:
    While Not Val(strInput) >= 0
        strInput = InputBox("This option allows you to increase or " & vbCRLF & "decrease (using decimals) all ingredients by" & _ 
                        vbCrLf & "the factor you enter below. To double the # of" & vbCrLf & "servings the recipe makes, enter a factor", "Factor", 0)
    Wend
    Recommend no spaces in any names of anything.
    Last edited by June7; 12-07-2017 at 09:06 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    CHEECO is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    156
    Your first code is working, but the command is not exiting. The mouse curser just keeps spinning until I close the Data Base. The code now looks like the following

    Code:
    Option Compare Database
    Option Explicit
    
    Private Sub Form_Current()
        If IsNull(Me![RecipeID]) Then
          DoCmd.GoToControl "RecipeName"
        End If
    End Sub
    Private Sub FoodCategoryID_NotInList(NewData As String, Response As Integer)
        MsgBox "Double-click this field to add an entry to the list."
        Response = acDataErrContinue
    End Sub
    Private Sub FoodCategoryID_DblClick(Cancel As Integer)
    On Error GoTo Err_FoodCategoryID_DblClick
        Dim lngCategoryID As Long
        If IsNull(Me![FoodCategoryID]) Then
            Me![FoodCategoryID].Text = ""
        Else
            lngCategoryID = Me![FoodCategoryID]
            Me![FoodCategoryID] = Null
        End If
        DoCmd.OpenForm "Food Categories", , , , , acDialog, "GotoNew"
        Me![FoodCategoryID].Requery
        If lngCategoryID <> 0 Then Me![FoodCategoryID] = lngCategoryID
    Exit_FoodCategoryID_DblClick:
        Exit Sub
    Err_FoodCategoryID_DblClick:
        MsgBox Err.Description
        Resume Exit_FoodCategoryID_DblClick
    End Sub
    Private Sub Multiply_Click()
        Dim rst As Recordset
        Dim dblFactor As Double
        'On Error GoTo Multiply_Err
        DoCmd.OpenForm "Multiply Dialog", , , , , acDialog
        
        'If Not IsLoaded("Multiply Dialog") Then
            'Exit Sub
        'End If
        If CurrentProject.AllForms("Multiply Dialog").IsLoaded Then
            If IsNull(Forms![Multiply Dialog]![Factor]) Or Forms![Multiply Dialog]![Factor] = 0 Then
                DoCmd.Close acForm, "Multiply Dialog"
                Exit Sub
            Else
                DoCmd.Hourglass True
                dblFactor = CDbl(Forms![Multiply Dialog]![Factor])
                Set rst = Me![Recipes Subform].Form.RecordsetClone
                rst.MoveFirst
                While (Not (rst.EOF))
                    rst.Edit
                    rst![Quantity] = rst![Quantity] * dblFactor
                    rst.Update
                    rst.MoveNext
                Wend
                Me.SetFocus
                Me![NumberofServings] = Forms![RECIPES]![NumberofServings] * dblFactor
                rst.Close
            End If
        End If
    End Sub

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Did not tell you to remove the Multiply_Exit: and Multiply_Error: branches. You removed the DoCmd.Hourglass False line.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    CHEECO is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    156
    You are correct. Put them back and everything is working fine. Thank-you so much June 7

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

Similar Threads

  1. Replies: 2
    Last Post: 09-01-2016, 11:00 AM
  2. Replies: 3
    Last Post: 07-07-2016, 12:22 PM
  3. Replies: 1
    Last Post: 09-07-2015, 08:00 AM
  4. Replies: 2
    Last Post: 05-20-2015, 08:26 AM
  5. Replies: 1
    Last Post: 09-19-2013, 11:42 AM

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