Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    corrie is offline Novice
    Windows 8 Access 2013
    Join Date
    Oct 2015
    Posts
    8

    Openform in 'Dialog' seems not to work. Processing in the call routine continues.

    Here is the copied


    Code:
    Private Sub DRAcc_DblClick(Cancel As Integer)
    DoCmd.Close acForm, "SelectAccount", acSaveNo
    DoCmd.OpenForm "SelectAccount", acFormDS, , , acFormReadOnly, acDialog, "DrAcc"
    Beep
    DRAName = DLookup("AccName", "AccountChart", "AccNumber = '" & DRAcc & "'")
    Let DRCTL = DLookup("AccControlled", "AccountChart", "AccNumber = '" & DRAcc & "'")
    
    
    DRAmount.SetFocus
    
    
    End Sub
    Now the way I understand it (if one can understand stuff at age 66 that is), is that when the [DoCmd.OpenForm "SelectAccount", acFormDS, , , acFormReadOnly, acDialog, "DrAcc"] executes, the called form "SelectAccount" should open as a popup, and execution of the rest of the code should hold back until the called form is closed.

    However, in my effort, the form opens as it should, but processing continues (I hear the beep), which also causes a problem as the rest of the code (DRAmount.SetFocus) fails as it is only once the called process is reacted on, that I have the required details.

    Have I got my story wrong or is the code just not right? The code above is exactly as it appears in my calling form's module. The called form just allocates the selected account number to the calling form. It is just a case of the calling process continuing when I thought it won't. (That is why I added the beep in the calling code sequence).

    Will be great to get this resolved - thanks.
    Last edited by corrie; 10-01-2015 at 07:58 AM. Reason: Just highlighting some words for emphasis and clarity.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    The acDialog should be working as you expect. The one thing that stands out to me is ...
    Code:
    DoCmd.Close acForm, "SelectAccount", acSaveNo
    If the form you are closing is the one where your code is executing, this line may be trumping the acDialog.

    Also, acSaveNo is a design time command and it is rarely, if ever, used. I suggest leaving it off.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Another thought is to check for code running in the open or load events of SelectAccount. Your code looks correct to me.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    corrie is offline Novice
    Windows 8 Access 2013
    Join Date
    Oct 2015
    Posts
    8
    The code closes the form that is being opened again directly after that. It is the form being called, and not the one in which the code is run. I actually added that to see if it is not a case of the form already being open from a previous call.. so the error was there even BEFORE I added that.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    acDialog has never failed for me.

    Don't quite follow your last post corrie.
    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.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I'll get out of the way.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    corrie is offline Novice
    Windows 8 Access 2013
    Join Date
    Oct 2015
    Posts
    8
    The called form displays a datasheet showing a list of account numbers and names... there is no actions on opening or loading.
    In that form, the only code is activated when the user dbl-clicks on the account number he wants.
    Code:
    Option Compare Database
    
    
    Private Sub AccNumber_DblClick(Cancel As Integer)
    If OpenArgs = "Dracc" Then
        Let [Forms]![JournalEntry]![DRAcc] = AccNumber
        
        Let [Forms]![JournalEntry]![DRAName] = DLookup("AccName", "AccountChart", "ACCNumber = [Forms]![JournalEntry]![DRAcc]")
        
    
    
        
        
    End If
    
    
    If OpenArgs = "Cracc" Then
        Let [Forms]![JournalEntry]![CRAcc] = AccNumber
        Let [Forms]![JournalEntry]![CRAName] = DLookup("AccName", "AccountChart", "ACCNumber = [Forms]![JournalEntry]![CRAcc]")
    End If
    
    
    DoCmd.Close acForm, "SelectAccount", acSaveNo
    
    
    End Sub
    That is the total of code in the called form.

    It actually works - but only after an error appears when the form is opened (from the other code first shown) - perfectly.

    Some things get me stunned - this is one of them.

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by corrie View Post
    The code closes the form that is being opened again directly after that...
    I see that, now. Perhaps you can go to form SelectAccount and open it in Design View. I suggest setting the Modal property to = Yes.

    If that does not help, place the code you want to run in a separate procedure within the initial form's module. Something like ...
    Code:
    Public Sub MyNewSub()
    DRAName = DLookup("AccName", "AccountChart", "AccNumber = '" & DRAcc & "'")
    Let DRCTL = DLookup("AccControlled", "AccountChart", "AccNumber = '" & DRAcc & "'")
    
    DRAmount.SetFocus
    End Sub
    Then, in the pop-up form's Unload event, call the sub you just built.
    Code:
    Forms!FormName.MyNewSub

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    What error? What is its exact message? I don't see it mentioned in earlier posts.

    If you want to provide db for analysis, follow instructions at bottom of my post.
    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
    corrie is offline Novice
    Windows 8 Access 2013
    Join Date
    Oct 2015
    Posts
    8
    I have used it often (kind of) and it always works fine for me too. This time is different though!

  11. #11
    corrie is offline Novice
    Windows 8 Access 2013
    Join Date
    Oct 2015
    Posts
    8
    The form is actually quite simple - and the called form (SelectAccount) is intended to be used in conjunction with other procedures too - what gets me though, is the fact that the modality appears not to be working.
    I need to resolve this as I have more places where the exact same situation, using the same 'SelectAccount' form is to be used.
    Thanks for your input - it might be the way I should change my thinking, but for now I just don't want to change to a new style! The problem is that the 'beep' should only be audible when the called form is closed. The rest of the system relating to a rather wide application, is not the problem right now.

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Did you see post 9?
    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.

  13. #13
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    what gets me though, is the fact that the modality appears not to be working.
    Code can override most properties set while in design view of a Form Object. However, I do not see how acdialog or any other argument provided would conflict and create the symptoms you described.

    Perhaps there is corruption. I have battled corruption issues with form objects. The symptoms, although not the same symptoms you describe here, had me focused on an OpenForm with acdialog line. I recreated the form, carefully copying stuff over. I did the compile thing. I did the compact and repair thing. In the end, I triumphed.

  14. #14
    corrie is offline Novice
    Windows 8 Access 2013
    Join Date
    Oct 2015
    Posts
    8
    I mentioned the error in my original post and explained it as best I can. It relates to a statement AFTER the original modal opening of the form 'SelectAccount'.
    It says: Run-time error 2110 - 'Moerkampkoffie can't move the focus to the control DRAccout'

    (Moerkampkoffie is the name of my database - we roast coffee, and my third language is English - (MoerKampKoffie means 'grainbrewed camping coffee')
    If I can't come right, I will certainly make use of your offer to send the database - or part of it anyway - for analysis.

    In access, when I select the 'debug' option on the error popup, it takes me to the relevant line which is AFTER the call, and the 'called' form is still open. I select the [END] option, then all works fine.

    Thanks so far anyway - and please forgive my weak command of the English language and Access terminology.

  15. #15
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Usually helps to provide exact message. The message references DRAccout but the code reference DRAmount. DRAmount is on the called form? Why do you need to explicitly set focus? Why not let focus go to control that has TabOrder 0?
    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.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 11-26-2013, 09:20 AM
  2. Command continues to popup message box..
    By Stephanie53 in forum Forms
    Replies: 12
    Last Post: 05-30-2013, 02:23 PM
  3. Replies: 3
    Last Post: 02-09-2011, 07:43 AM
  4. Replies: 7
    Last Post: 01-19-2011, 10:39 AM
  5. Issues with Continues form
    By ducecoop in forum Access
    Replies: 3
    Last Post: 11-11-2010, 01:18 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