Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2007
    Location
    Wichita, KS
    Posts
    7

    Unanswered: Listbox.Selected method causing navigation issues

    I've an unbound listbox that I populate with the result of a simple query during the Form's OnCurrent event. I wish to display a specific row in this listbox as selected, but when that specific line (shown below) is included in my code, when I try to navigate from one record to another, I get "Update or CancelUpdate without AddNew or Edit." There is no indication that the form/data is "dirty" (and I'm not, as far as I'm aware, changing any data in code), but if I press [Esc], I can move to the next record (where I encounter the same problem). If my cursor is in a multi-line text field, I do not have this issue, and can scroll through records indiscriminately. If I remove the line
    Code:
    listbox.Selected(rownum)=True
    everything works fine, but the row in the listbox is, of course, not selected as I want it to be. This issue has thoroughly stumped me...any ideas?

  2. #2
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    You should be able to just use
    me!MyListBox = "StringValue" '<- where StringValue is the value you want selected for the listbox

    or

    me!MyListBox = IntegerValue '<- where IntegerValue is the value you want selected for the listbox

    instead of

    listbox.Selected(rownum) = True

    Maybe this isn't what you want though as I don't think it will highlight it in the listing but it will put the value in the field.

    Otherwise, I have to ask if the unbound listbox isn't perhaps bound and there isn't something in the ControlSource line for the listbox. I once made a table with 1 field specifically for an unbound listbox which I then made bound to this 1 field in the table (although I can't recall specifically why I did it as it was years ago.)
    Last edited by pkstormy; 04-25-08 at 22:55.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  3. #3
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Maybe this isn't what you want though as I don't think it will highlight it in the listing but it will put the value in the field.
    Yes it will. There is no "field" part to a list box; the list box is the field.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  4. #4
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    I stand corrected.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  5. #5
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Nah, you just stand correct.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  6. #6
    Join Date
    Nov 2007
    Location
    Wichita, KS
    Posts
    7

    Thanks

    Thanks--works great!

Posting Permissions

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