Results 1 to 11 of 11
  1. #1
    Join Date
    Jun 2004
    Posts
    8

    Unanswered: simple listbox question

    hello, i have a form with some text boxes on it and 1 list box. the list box is populated based on a sql select statemetn. my question is, the list box works fine with populating data, however the text boxes dont reflect the data in the list box until i manually click on one of the list box entries. how do i do it so that when the form comes up, the first item in the list box is already selected? do i have to use this somehow?

    List114.Selected(0) = True

    i tried putting that in the after update section but it didnt work?
    Thanks, any help is appreciated

  2. #2
    Join Date
    Mar 2004
    Location
    www.scirocco.ca
    Posts
    346
    Type this instead:

    Code:
    List114.ListIndex = 0
    http://www.scirocco.ca/images/banner...occobanner.gif

    Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!

    Or try our Ask An Expert service to answer any of your questions!

  3. #3
    Join Date
    Jun 2004
    Posts
    8
    hey, thanks for the help, i tried putting that in the after update but then i got an error this is the debug


    Code:
    Private Sub List114_AfterUpdate()
        List114.ListIndex = 0
        ' Find the record that matches the control.
        Dim rs As Object
    
        Set rs = Me.Recordset.Clone
        rs.FindFirst "[ID] = " & Str(Nz(Me![List114], 0))
        If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    End Sub

  4. #4
    Join Date
    Apr 2003
    Location
    Alabama, USA
    Posts
    154
    No End If?
    http://AccessDB.Info

    You live and learn. At any rate, you live. - Douglas Adams

  5. #5
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    Hi

    What is the error message

    If ID is text as CStr implies then perhaps you could try this with apostophies

    rs.FindFirst "[ID] = '" & Str(Nz(Me![List114], 0)) & "'"

    If the error is on the Bookmark statement, then isprobaply not found the ID (possibly because of above).

    The using
    if not rs.nomatch then Me.Bookmark = rs.BookMark

    Also it should be Me.RecordsetClone not ME.Recordset.Clone !!??


    HTH

    MTB

  6. #6
    Join Date
    Jun 2004
    Posts
    8
    thanks for the replies. just to double check, i am putting these statemetns in the After Update section, is that would i should be doing?

    i tried using

    rs.FindFirst "[ID] = '" & Str(Nz(Me![List114], 0)) & "'"

    however, that didnt work. the error i get when i use

    List114.ListIndex = 0

    is this
    Attached Thumbnails Attached Thumbnails untitled.jpg  

  7. #7
    Join Date
    Jan 2004
    Location
    Vancouver, WA
    Posts
    41
    Cosmos,

    End If is not needed when the entire statement is on one line...

    If a = b Then
    c = d
    End If

    ... is the same as:

    If a = b Then c = d

  8. #8
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Um ... Try:

    MyListBox.Value=MyListBox.Column(MyListBox.BoundCo lumn,0)
    Back to Access ... ADO is not the way to go for speed ...

  9. #9
    Join Date
    Jun 2004
    Posts
    8
    nope, that didnt work either this is the error i get
    Attached Thumbnails Attached Thumbnails untitled.jpg  

  10. #10
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    Hi again

    Could you post the all the code for the after_update event and advise on which line the 2115 error occurs ?

    MTB

  11. #11
    Join Date
    Apr 2003
    Location
    Alabama, USA
    Posts
    154
    Quote Originally Posted by mtnorwood
    Cosmos,

    End If is not needed when the entire statement is on one line...
    Thanks! Learn something new every day!
    http://AccessDB.Info

    You live and learn. At any rate, you live. - Douglas Adams

Posting Permissions

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