Mouse events on a form (1 Viewer)

HealthyB1

Registered User.
Local time
Today, 22:40
Joined
Jul 21, 2013
Messages
96
G'day,
I am in need of some help please.
I have a parts order form (FrmORDER)with a list of parts selected stored in it. e.g Part #, Part Description, Qty, Price etc
I also have assemblies stored with the same detail that are composed of individual parts.

What I would like to do is

  • open formA if I do a single click (to select a new part or assembly)
  • Open formB if I do a double click (to open the contents of the selected assembly in the order form
It would seem that the following series of events occurs
When the user double-clicks a control other than a command button: MouseDown → MouseUp → Click → DblClick → MouseUp

Hence I can't actually open formB with a double click unless I remove the single click event.

Does any one have any suggestions on how to get around this problem or recommend and alternative way to solve the problem

Thanks in advance,
 

Ranman256

Well-known member
Local time
Today, 08:10
Joined
Apr 9, 2015
Messages
4,339
What are you 'clicking'?
Usu a user picks a list and dbl-clicks the item to open.
This is a click event ,not a mouse event.
 

HealthyB1

Registered User.
Local time
Today, 22:40
Joined
Jul 21, 2013
Messages
96
Hi Ranman,

You are correct the Title should be "mouse clicks on a form"
I have a parts ordered list as you suggested on a form called FrmOrder.
At the present moment a single click on an item opens a form called FormA that allows me to select new items to add to the parts ordered list.

I can select from FormA individual parts or items or alternatively an assembly of parts (or kit of parts) that I can add to FrmOrder.

What I want to be able to do on FrmOrder is select an assembly from the list then double click it to look at the contents of the assembly.

Simple example:-
I can order 5 individual vegetables to make a pot of soup.
Alternatively I can order a prepacked tray of "soup vegetable mix" from the green grocer.

What I want to be able to do on the order placed is open the "soup vegetable mix" and see if I need more carrots or onions or celery to add to the mix. As the "soup vegetable mix" is prepacked I can't modify same. However I should be able to separately add orders for more carrots or onions.

I have tried programming using VBA for a single click on a list item to open FormA which works perfectly.
I have also been able to program a double click to open formB which works perfectly providing there is no single click event set up.

Unfortunately with both a single click event and a double click event programmed in VBA the single click event takes precedence. Is there another way I can do this or can you suggest a work around??

The issue is that it seems i
 

MarkK

bit cruncher
Local time
Today, 05:10
Joined
Mar 17, 2004
Messages
8,178
You can set a timer on click. Then, if a double-click event occurs, cancel the timer. If the timer event fires, the double-click didn't fire, and you can just treat it as a click. So, pseudocoded . . .
Code:
On Click
- set timer
On Double Click
- cancel timer
- do double click
On Timer
- do click
Makes sense?
 

HealthyB1

Registered User.
Local time
Today, 22:40
Joined
Jul 21, 2013
Messages
96
Re: Mouse clicks on a form

G'day MarkK,

That's for the suggestion. It makes sense to me. I'll give it a try and let you know.
Cheers
 

HealthyB1

Registered User.
Local time
Today, 22:40
Joined
Jul 21, 2013
Messages
96
Hi MarkK,

I don't seem to be able to find the timer event unless I look at the events for the whole form.
I really want to set the timer when I click the field in the record. Can you give the code snippet to do this please?
Cheers,
HB
 

MarkK

bit cruncher
Local time
Today, 05:10
Joined
Mar 17, 2004
Messages
8,178
Code:
Private Sub txtSomeField_Click()
[COLOR="Green"]   'to start the timer we just set the timer interval to a non-zero amount
   'timer interval is measured in milliseconds[/COLOR]
   Me.TimerInterval = 150
End Sub

Private Sub txtSomeField_DblClick()
[COLOR="Green"]   'to cancel the timer, we set the timer interval to zero[/COLOR]
   Me.TimerInterval = 0
   DoDoubleClickRoutine
End Sub

Private Sub Form_Timer()
[COLOR="Green"]   'if the timer fires, then it was not cancelled by a double click, so 
   'we assume a valid click occurred, and we cancel the timer.[/COLOR]
   Me.TimerInterval = 0
   DoClickRoutine
End Sub

See if that works. Let me know. I did not test this.
 

HealthyB1

Registered User.
Local time
Today, 22:40
Joined
Jul 21, 2013
Messages
96
Hi MarkK,

It works perfectly. Many thanks.
I owe you a beer when next you are in Australia
 

MarkK

bit cruncher
Local time
Today, 05:10
Joined
Mar 17, 2004
Messages
8,178
No I haven't. I've been to South America and Antarctica though, so some southern hemisphere destinations, but not Australia. Yet . . .
 

Users who are viewing this thread

Top Bottom