Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2004
    Posts
    100

    Unanswered: Strange listbox problem

    In VBA I have the form select a specific item in the listbox using:

    Me.MonthlyEnd.Selected(Me.MonthlyStart.ListIndex) = True

    The item then becomes highlighted on the screen. But strangely, the listbox value is not showing the highlighted value. The value showing for Me.MonthlyEnd.Value is -1. How can get the value of the item highlighted without the user clicking on it? If the user clicks on the item it works fine.

    Thanks!

    Norm

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Did you try the Refresh method? Ex: Me.ListBoxControl.Refresh ...

  3. #3
    Join Date
    Jan 2004
    Posts
    100
    Originally posted by M Owen
    Did you try the Refresh method? Ex: Me.ListBoxControl.Refresh ...
    I wasn't able to seem to get refresh to work.

    I created a small database to show the problem I am experiencing.

    If you look click a date in the "Beginning Date" listbox a corresponding date in the "Ending Date" listbox will be highlighted. I also set it up so the value of the "Ending Date" Listbox is shown in the "Should Show Here" textbox. You will also see the textbox remains blank as does the value of the "Ending Date" listbox shown in the watch window.

    Thanks for your help!

    Norm
    Attached Files Attached Files
    Last edited by norm801; 01-26-04 at 17:34.

  4. #4
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Originally posted by norm801
    I wasn't able to seem to get refresh to work.

    I created a small database to show the problem I am experiencing.

    If you look click a date in the "Beginning Date" listbox a corresponding date in the "Ending Date" listbox will be highlighted. I also set it up so the value of the "Ending Date" Listbox is shown in the "Should Show Here" textbox. You will also see the textbox remains blank as does the value of the "Ending Date" listbox shown in the watch window.

    Thanks for your help!

    Norm
    Norm,

    Try this:

    Code:
    Private Sub MonthlyStart_Click()
        'If Me.SingleMonthCheck = -1 Then
        If MonthlyStart.ListIndex <> -1 Then
            Me.MonthlyEnd.Selected(Me.MonthlyStart.ListIndex) = True
            'Me.EndingDateResult = Me.MonthlyEnd.Value
            EndingDateResult.Value = MonthlyEnd.Column(0, MonthlyStart.ListIndex)
        End If
    End Sub
    This works for what you gave as an example ...

  5. #5
    Join Date
    Jan 2004
    Posts
    100
    Originally posted by M Owen
    Norm,

    Try this:

    Code:
    Private Sub MonthlyStart_Click()
        'If Me.SingleMonthCheck = -1 Then
        If MonthlyStart.ListIndex <> -1 Then
            Me.MonthlyEnd.Selected(Me.MonthlyStart.ListIndex) = True
            'Me.EndingDateResult = Me.MonthlyEnd.Value
            EndingDateResult.Value = MonthlyEnd.Column(0, MonthlyStart.ListIndex)
        End If
    End Sub
    This works for what you gave as an example ...
    Perfect!

    The missing link was the line:

    EndingDateResult.Value = MonthlyEnd.Column(0, MonthlyStart.ListIndex)

    Thanks for the help!

    Norm

Posting Permissions

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