Combo Needs 2 Click to Stay Open?
A2k (9.0.3821) SR-1
The the attached db is from roger
Combo Needs 2 Click to Stay Open?
A2k (9.0.3821) SR-1
The the attached db is from roger

This month, every Windows Secrets subscriber can download a one-chapter excerpt of Windows 7: The Missing Manual.Windows 7: The Missing Manual provides valuable information to help you overcome these difficulties in learning a new operating system. Subscribe today to download your free excerpt.
In the mouse up event change your code to :
<pre>Private Sub TRAINING_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If X < 2400 Then
Me!TRAINING.SelStart = 0
Me!TRAINING.SelLength = Len(Nz(Me!TRAINING.Column(1)))
End If
End Sub</pre>
X is the width position of the cursor when you release the mouse.
Your control training.width = 2640.
2400 is about the width of the control minus the arrow width, maybe you'll have to adjust it a little.
Francois
http://www.wopr.com/S/Belgium.gif
Hi Francois
Worked fine, what did I do?
I see the control width is 1.833, where does 2640 come from (1.8333 X 1440)?
What is 1440?
Is mouse up event the proper place to do this?
Is there a better way to accomplish my objective?
Is there way to make the following dynamic?
If X < 2400 Then
Thanks, John
When you work with width and height in VBA the unit of measurement is twips.
From the help file :
Twip: Units of measurement use by Microsoft Access that is equal to 1/20 of a point, or 1/1440 of an inch. There are 567 twips in a centimeter.
If your control is 1.833 inch, then it is 1.833 * 1440 = 2640 twips.
By trying and debugging I find that the width of the arrow = +/- 240 twips.
If you want to use it dynamic you could use :
If X < Me.Training.Width - 240 Then
When I say that you may have to adjust it, it's because I don't know what resolution you use and don't know if 240 is accurate enough for yours
Francois
http://www.wopr.com/S/Belgium.gif
Hi Francois
I was able to streamline this, it works, can you make any improvements?
Thanks, John
Private Sub lngKey1ID_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
' this combo has autonumber (0) and description (1) 1 = column 1 is description
Button = Combo_MouseUp(Me!lngKey1ID, 1, Button, Shift, X, Y)
End Sub
Function Combo_MouseUp(cbo As ComboBox, Col As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
' combo has autonumber (0) and description (1) 1 = column 1 is description
' combo has description (0) only 0 = column 0 is description
Dim ctl As Control
Set ctl = cbo
If X < ctl.Width - 240 Then
ctl.SelStart = 0
ctl.SelLength = Len(Nz(ctl.Column(Col)))
End If
End Function
Seems to work perfectly. No improvements I can think.
Francois
http://www.wopr.com/S/Belgium.gif
'Scuse me for butting in here. I might be very stupid, but the code as posted seems strange. Perhaps you left out some lines.
The function Combo_MouseUp doesn't return a value as far as I can see, so the assignment
Button = Combo_MouseUp(...) always ends up setting Button = 0.
(And the variable ctl seems superfluous, why not use cbo throughout?)
Hark
Hans can make that code work in 2 less statements
Thanks for your help.
Private Sub lngKey1ID_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
' this combo has autonumber (0) and description (1) 1 = column 1 is description
Call Combo_MouseUp(Me!lngKey1ID, 1, Button, Shift, X, Y)
End Sub
Sub Combo_MouseUp(cbo As ComboBox, Col As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If X < cbo.Width - 240 Then
cbo.SelStart = 0
cbo.SelLength = Len(Nz(cbo.Column(Col)))
End If
End Sub