Unable to copy text from locked textbox in 2007 form opened with acDialog window mode

I've got a custom copy function (below) which is called via a shortcut menu in a variety of my forms.  This function generally works quite well, but I recently discovered that when I call this code from a form that was opened with the acDialog window mode, it does not work.

Public Function fnTextCopy()

    Dim frm As Form
    Dim ctrl As Control
   
    Set frm = Screen.ActiveForm
    Do While frm.ActiveControl.ControlType = acSubform
        Set frm = frm.ActiveControl.Form
    Loop
    Set ctrl = frm.ActiveControl
   
    If ctrl.SelLength = 0 Then
        ctrl.SelStart = 0
        ctrl.SelLength = Len(ctrl.Text)
    End If
   
    DoCmd.RunCommand acCmdCopy
       
End Function

If I put a breakpoint on the "End Function" line, then I can go to the immediate window and paste the copied value (either with Ctrl-V or the right-click shortcut menu), but as soon as the function exits, the clipboard seems to drop the copied text.  Interestingly, Ctrl-C does not work to copy text from these textboxes either.  When I open the form without the "acDialog" window mode, the code and Ctrl-C both work.  When I set the forms modal property to true, I was able to drop the acDialog window mode from the FormOpen method, and the function and Ctrl-C both work as well, so this is how I will resolve my issue.  

But that still leaves the question, why won't this work when opened with acDialog window mode?  Is this a bug?
LVL 50
Dale FyeAsked:
Who is Participating?
 
Dale FyeAuthor Commented:
am troubleshooting now.

I was going to send a sample database this AM.  I built this new one from scratch (imported my menu code and functions) but when I got done, I could not duplicate the problem.  So, now I'm going back to the original db and taking a look at the form to see if there is something else going on.  Will post back.
0
 
Rey Obrero (Capricorn1)Commented:
when a form is opened with acDialog window mode,
that form will have the focus, suceeding codes from where the form was open will be at halt, and will continue only when the form opened in modal mode was closed.
0
 
Dale FyeAuthor Commented:
That is not the issue.

fnTextCopy() is called by a shortcut menu, which is called from within any of the textboxes in the form that was opened with acDialog.

The function runs fine, its just that the clipboard seems to loose the copied text as soon as the function exits.  As I stated, if I drop acDialog and change the forms modal property to True, the form opens modal, and the function works fine.  That is why I'm inclined to thing there is a bug.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Rey Obrero (Capricorn1)Commented:
with acDialog, the forms modal and popup property are set to yes
0
 
Dale FyeAuthor Commented:
Understood!

But the question is, why is Access preventing me from copying text (Ctrl-C or my function) from a textbox on a form that is opened with acDialog?
0
 
Rey Obrero (Capricorn1)Commented:
can i see your form?
0
 
Rey Obrero (Capricorn1)Commented:
i did made a test and i could copy the contents of the textboxes with ctrl + c

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.