Results 1 to 3 of 3

Thread: ADODB & List boxes

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2001
    Posts
    3

    Question ADODB & List boxes

    I am stuck on a slight programming problem:

    I have a form that provides name number etc from a database using the activex db control (called adoDataControl). I can manage this bit OK. When I load the form I also call a procedure to populate a list box from another table usin a seccond ado activex control (Called adoExtraDetails). My naminc convention needs a little work I Know!

    This works for the 1st time I open the form, but when I change the main record(Name number etc) the information in the list box changes.

    I am querying the ID fro mthe main form each time I change record: See code below:

    Public Function PopulateListBox()

    On Error GoTo Err_PopList
    With frmJobDetailsReview

    .adoExtraDetails.ConnectionString = .adoDataControl.ConnectionString
    .adoExtraDetails.RecordSource = "SELECT * FROM ContactDetails WHERE ID = " & .adoDataControl.Recordset!ID
    Set .lstDateContact.DataSource = .adoExtraDetails
    If .adoExtraDetails.Recordset.RecordCount > 0 Then
    .adoExtraDetails.Recordset.MoveFirst
    Do While Not .adoExtraDetails.Recordset.EOF
    .lstDateContact.AddItem .adoExtraDetails.Recordset!ContactDate & "; " & .adoExtraDetails.Recordset!ContactTime
    .adoExtraDetails.Recordset.MoveNext
    Loop
    .lstDateContact.Refresh

    End If
    End With
    GoTo NoErr

    Err_PopList:

    MsgBox Err.Description

    NoErr:

    End Function

    Any Help is greatly appreciated
    Regards

    Julian Brunt

  2. #2
    mcsd2002
    Guest
    It looks to me like your code was written to do exactly what you seem to be having trouble with. Each time you call the populatlistbox function you base the data on a new ID. I would fully expect the details to change each time you selected a new record. What's the problem?

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2001
    Posts
    3
    The problem is that all I see is the results from the 1st entry when the form was loaded. Subsequent changes show the same value.

    Should I be putting in a .AbsolutePosition or similar somewhere. I have tested the SQL statement and it does produce the correct number for ID, but all I ever seem to get is the entry results.

    I have attached the whole project and db

    Choose options, specify the locastion for the db



    then back @ the main form review the jobs.
    Regards

    Julian Brunt

Posting Permissions

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



Click Here to Expand Forum to Full Width