Order Double-Click in VBA
SolvedTessel75 -
Hello,
In my program, I open a form, go to a control, and double-click.
In VBA, I know how to write all of this, except for the double-click.
Does anyone know the magic command for double-clicking?
I have tried a lot of things but haven't succeeded. In particular via DoCmd.RunCommand.
Thank you for your insights.
8 answers
Hello,
can you follow up on the previous discussions that you left pending?
"I'm on a control": is the cursor therefore properly positioned on this control?
Maybe show us everything you've tried; this will help us better understand the context, potentially correct an error, and avoid proposing a solution that doesn't suit you.
You don't specify whether your program and your control are in Access or if the form is in another software.
If you explain your context and your goal, we might be able to suggest another method than double-clicking.
Hello YgBe,
My initial question was posted on the discussion group Database / Access, so my question is indeed about VBA-Access which I am working with. Someone changed the location of my question, probably rightly so, but initially this clarification was not necessary.
Now, I want to clarify that with VBA, I open a certain form and select a certain control on this form. This poses no difficulty for me. However, this control necessarily requires a double-click to open, so I would like this double-click to be triggered by the program rather than having to perform it manually every time.
I reiterate that I have searched many methods without finding one, I cannot list them all, but especially Cmd.RunCommand ??? and Cmd.?????. As for the rest and to answer your question: Yes, I am indeed on Access, and all my objects are on the same DB, and the desired action cannot be substituted by another for the simple reason that it is the default action of the DblClick on these controls, in this case a Attachments control (in VBA, "Attachment").
You select a certain control, so the cursor is not positioned on that control, is that correct? The control simply has the "focus"?
It's not enough just to double-click; you need to position the cursor on the control first, it seems to me.
When you say "default action," do you mean that you haven't programmed anything for that control, nothing configured as a specific action? There is no associated VBA code for that control, nor any macro?
And I assume you don't want to configure anything for these controls?
Feel free to explain what you are actually trying to achieve, as it might give us some ideas for suggestions.
Below is my summary code with the successive orders. There are only 2 lines
1 ==> DoCmd.OpenForm "F_PiecesJointesSpecifiques", acNormal, "", "[LienPJAppart] = ???? and [CodeLienPJ] = ??? ", , acNormal
2 ==> Forms!F_PiecesJointesSpecifiques!Control_PiècesJointes.SetFocus
So I open the form "F_PiecesJointesSpecifiques", and I set the focus on the control "Control_PiècesJointes" that I double-click on.
However, I would like that this double-click be performed programmatically.
But I have searched on my favorite browser without finding what I am looking for, and I am starting to believe that it is not possible. There is the event "DblClick" or the property "OnDblClick", but there is no method that is the way to trigger an event.
Control "AttachedFiles" or "Control_AttachedFiles"?
Because you just have to open this control when you open "F_SpecificAttachedFiles", right?
I'm missing something...
See you blux "The fools dare anything.
It's even how you recognize them."
Indeed, while Tessel75 is asking how to double-click, he ultimately explains that he actually wants to open a control. The double click therefore seems, from the beginning of this discussion, to be a distraction, a red herring.
On one hand, VBA does not allow to trigger events such as double clicks.
On the other hand, before double-clicking, the cursor must be positioned on the control, which "setfocus" obviously does not do.
I do not have an example of a form with a control of this type, and I have not managed to create one that works. Therefore, I cannot test it. Otherwise, I would be happy to test to discover:
- the methods available in VBA for controls of this type. According to the documentation and what I have been able to test (too little), not much
- what a user can do to "open" this kind of control. Is it possible for a user to do this without double-clicking, using only the keyboard? It is easier in VBA to "type" keys on the keyboard than to position the cursor on a control.
The model for the "Attachments" controls can be found on the "Design" tab of the ribbon in the form opened in "Design" mode. These are very specific controls, similar to the "ListBox" or "ComboBox" controls, or even the "Dependent Object Frame". Therefore, the manipulations of these controls are particular. For the "Attachments" controls, double-clicking opens the list of linked attachments.
In response to Blux's question, "Control "Attachments" or "Control_Attachments", it's the same thing, one and the other; it's just that in my previous answer I referred to this control as "Attachments", "ControlAttachments".
I've got it!
The answer has nothing to do with "DblClick", except that the command does what you get by double-clicking.
So, if other people wanted to automatically open an "Attachments" control or in English-VBA "Attachment", you need to write the command;
"DoCmd.RunCommand acCmdManageAttachments"
Resolved
And thanks to the people who helped me look for it.