Results 1 to 8 of 8
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Combo Needs 2 Click to Stay Open? (Combo Needs 2 Click to Stay Open?)

    Combo Needs 2 Click to Stay Open?

    A2k (9.0.3821) SR-1

    The the attached db is from roger
    Attached Files Attached Files

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo Needs 2 Click to Stay Open? (Combo Needs 2 Click to Stay Open?)

    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

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo Needs 2 Click to Stay Open? (Combo Needs 2 Click to Stay Open?)

    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

  4. #4
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo Needs 2 Click to Stay Open? (Combo Needs 2 Click to Stay Open?)

    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

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo Needs 2 Click to Stay Open? (Combo Needs 2 Click to Stay Open?)

    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

  6. #6
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo Needs 2 Click to Stay Open? (Combo Needs 2 Click to Stay Open?)

    Seems to work perfectly. No improvements I can think.
    Francois

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Combo Needs 2 Click to Stay Open? (Combo Needs 2 Click to Stay Open?)

    '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?)

  8. #8
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo Needs 2 Click to Stay Open? (Combo Needs 2 Click to Stay Open?)

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •