Solved

Mouse Cursor Location and Form Behavior on Open

Posted on 2011-09-14
13
530 Views
Last Modified: 2013-11-28
I have a button on a form that raises another modal form.  Oddly (and disturbingly) the form that opens also sinks the mouse click.  So, in other words, the sequence of events is:

1) Click button on Form A
2) Button raises Form B
3) Form B also registers a click

That just won't do.  I don't feel like I should have to work around this with mouse events.  What's wrong here?

Mike
0
Comment
Question by:shacho
  • 9
  • 4
13 Comments
 

Author Comment

by:shacho
ID: 36540511
For reference, here is (approximately) the code that raises the form:
DoCmd.OpenForm "MyForm", acNormal, , "ID=111", acFormEdit, acDialog, "blah"

0
 
LVL 75
ID: 36540568

Try removing the acDialog and instead, set the Modal and Popup properties of MyForm to Yes.

DoCmd.OpenForm "MyForm", acNormal, , "ID=111", acFormEdit, , "blah"
0
 
LVL 75
ID: 36540571
"Form B also registers a click"

Also, not exactly sure what you mean by that ?

mx
0
 

Author Comment

by:shacho
ID: 36540720
I click the launch button in Form A, then Form B opens, and if there happens to be a button on B right underneath the mouse cursor, that button also gets pushed.

I have a routine that alters the row source of a control on Form B that runs when the form loads.  Somehow that process is messing things up.  If I block that code, the aforementioned phenomenon does not happen.

0
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Access MVP)
DatabaseMX (Joe Anderson - Access MVP) earned 500 total points
ID: 36540736
Well ... guess I would have to 'be there' on this one.  But did you try what I suggested above ... removing acDialog  etc.

mx
0
 

Author Comment

by:shacho
ID: 36540738
Strike that.  I got it now.  There's a control that drops down automatically on enter.  It's also the first control.  That dropping down is the cause of the problem.  I think it goes something like this: The list drops momentarily - then the row source is changed.  This cancels the drop, but Access assumes the drop was cancelled by a click so it looks for the location of the mouse cursor and clicks.
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Author Comment

by:shacho
ID: 36540751
Solved with a new understanding (thanks for that yesterday) of Key events.

Private Sub cbxItemType_KeyUp(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyTab Then Me.cbxItemType.DropDown
End Sub

Instead of ...

Private Sub cbxItemType_Enter()
    Me.cbxItemType.DropDown
End Sub
0
 

Author Comment

by:shacho
ID: 36540769
Nope - spoke too soon.  Still haven't worked it out.  More soon.
0
 

Accepted Solution

by:
shacho earned 0 total points
ID: 36540806
I really got it now.  You may remember this from yesterday.

"in the end i made two forms for the child table.  one is just a list with no code.  that one gets embedded as a locked subform, for which only two events exist: got and lost focus. if you click on or navigate to the subform with keys, it shows the real editor (the other form) then pushes the focus on to the next control.  it's soooooooo much easier and clear and reliable this way.  and it loads faster. "

So clicking in (or actually, "into") the subform triggers the launch of the form in question.  The subform is locked so the click "in" the subform appears to be a click "on" it.  In this way, it behaves like a button.  But the click ends up getting heard by the form that gets launched.  I don't know what happens behind the scenes, but somehow I suspect if the subform weren't locked, that click might get ignored by the pop up form.  I dunno.  Anyway, now I need to figure out how to work around this.  Bending Access form navigation behavior to your will sure takes a lot of stamina.

Mike

0
 

Author Comment

by:shacho
ID: 36540817
...and they call this "rapid" application development.
0
 

Author Closing Comment

by:shacho
ID: 36558857
-
0
 
LVL 75
ID: 36561059

Rapid is a Relative term.  At least it's not Rabid !!!

mx
0
 

Author Comment

by:shacho
ID: 36563455
Ha. You should have seen me after trying to troubleshoot this problem for 4 hours...
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now