Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2003
    Location
    London,UK
    Posts
    54

    Unanswered: populating a list box

    i have been working on a list box and now seems to be working, just one more thing left.

    I am able to populate the list box but it only displays the last column, although there are 6.

    here is the code--

    Private Sub Form_Load()
    Dim strSQL As String
    Dim strSQLArray As String
    Dim counter As Integer
    Dim listText As String
    counter = 0

    For counter = LBound(propertyListArray) To UBound(propertyListArray) - 1
    strSQLArray = strSQLArray & "((propfixedMade.propref="
    strSQLArray = strSQLArray & "'" & propertyListArray(counter) & "'"
    strSQLArray = strSQLArray & ")) OR "
    Next

    strSQLArray = Left(strSQLArray, (Len(strSQLArray) - 4))
    strSQLArray = strSQLArray & ")"
    strSQL = "SELECT propfixedMade.propref, propfixedMade.houseno, propfixedMade.proadd1, propfixedMade.proadd2, " & _
    "propfixedMade.proadd3 , propfixedMade.propstcde " & _
    "FROM propfixedMade " & _
    "WHERE ((propfixedMade.proclass)='R') AND ((propfixedMade.rentgpcode)='G1') " & _
    "AND ("

    strSQL = strSQL & strSQLArray
    Text56.Value = strSQL
    createRecordset (strSQL)

    lstCPLPropertiesInList.ColumnCount = 6
    lstCPLPropertiesInList.ColumnWidths = "1;2;2;2;2;2"


    While rs.EOF = False
    listText = listText & rs("propref").Value & "," & rs("houseno").Value & ","
    listText = listText & rs("proadd1").Value & "," & rs("proadd2").Value & ","
    listText = listText & rs("proadd3").Value & "," & rs("propstcde").Value & ";"

    rs.MoveNext
    Wend

    rs.Close
    Set rs = Nothing
    lstCPLPropertiesInList.RowSource = listText
    End Sub


    any help

    thanks in advance

  2. #2
    Join Date
    Aug 2003
    Location
    Bosnia & Hercegovina
    Posts
    57
    you'll have to use AddItem method, it's simple.......

    just before you move to next record put this code:

    lstCPLPropertiesInList.AddItem listText

    and it will add one by one to your listbox....

  3. #3
    Join Date
    Aug 2003
    Location
    London,UK
    Posts
    54
    the addItem property is not available to me, why is this?

  4. #4
    Join Date
    Aug 2003
    Location
    Bosnia & Hercegovina
    Posts
    57
    are you sure you are using listbox and not the one from Microsoft Forms 2.0?

    check your data tab for this control......

  5. #5
    Join Date
    Aug 2003
    Location
    London,UK
    Posts
    54
    im running access 2000, when you click on the forms tab and create new form you get a small tool box where i have used the listbox from there, draged and sized up in the correct place in the form.

    which one have i used?

  6. #6
    Join Date
    Aug 2003
    Location
    Bosnia & Hercegovina
    Posts
    57
    you probably used normal one.....

    it should have additem method.....

    what does it say on your data tab?

    can you pick value list as source instead of table/query?

  7. #7
    Join Date
    Aug 2003
    Location
    London,UK
    Posts
    54
    yep i can pick value list, and field list!!!

  8. #8
    Join Date
    Aug 2003
    Location
    Bosnia & Hercegovina
    Posts
    57
    well try with value, don't type the values, you'll add those from code...

    got to run now....

Posting Permissions

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