Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Join Date
    Nov 2003
    Posts
    32

    Unanswered: adding items to combo box during run time

    hello,

    i want to add items to the combo box during run time from the database. please help me in this matter.

    i tried using additem method, when i am trying to use that method i am getting the error "method not found". i saw in the object browser also but i did not find the "additem" method.

    Please help me in the matter

    How can i add items at runtime into the combo box.

    i am using access 2000

    pleaseeee help me

    thanks

    annam

  2. #2
    Join Date
    Feb 2002
    Posts
    2,232
    What is the code you are using to use the additem method ?

  3. #3
    Join Date
    Nov 2003
    Posts
    32
    The following is the code

    Private Sub Form_Load()
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Set db = OpenDatabase("Z:\profile\My Documents\csc6700_project\project proposals.mdb")
    Set rs = db.OpenRecordset("select * from tblPrincipalInvestigator")
    Do While Not rs.EOF
    Combo9.AddItem (rs(1))
    rs.MoveNext
    Loop
    End Sub

  4. #4
    Join Date
    Feb 2002
    Posts
    2,232
    What is the rowsourcetype for the combobox ?

  5. #5
    Join Date
    Nov 2003
    Posts
    32
    i set rowsource type to "value list"

  6. #6
    Join Date
    Nov 2003
    Posts
    32
    after we type the object name and '.' after that we will get a list of methods and properties. in that i am not able to find additem method in the list

  7. #7
    Join Date
    Feb 2002
    Posts
    2,232
    What is the list of available properties/methods that you do see ?

  8. #8
    Join Date
    Nov 2003
    Posts
    32
    addcolon, afterupdate, allowautocorrect......

  9. #9
    Join Date
    Feb 2002
    Posts
    2,232
    Are you sure that this is referencing a combobox ?

  10. #10
    Join Date
    Nov 2003
    Posts
    32
    yes

  11. #11
    Join Date
    Feb 2002
    Posts
    2,232
    Can you post the mdb ?

  12. #12
    Join Date
    Nov 2003
    Posts
    32
    Originally posted by rnealejr
    Can you post the mdb ?
    Attached Files Attached Files

  13. #13
    Join Date
    Feb 2002
    Posts
    2,232
    Try the following:

    Private Sub Form_Load()
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim strText as string

    Set db = OpenDatabase("Z:\profile\My Documents\csc6700_project\project proposals.mdb")
    Set rs = db.OpenRecordset("select * from tblPrincipalInvestigator")
    Do While Not rs.EOF
    if strText = "" then
    strText = rs(1)
    else
    strText = strText & "," & rs(1)
    end if
    rs.MoveNext
    Loop
    combo9.RowSource = strText 'fill the listbox
    End Sub

  14. #14
    Join Date
    Feb 2002
    Posts
    2,232
    If possible, post your files in zip format - winrar is not as popular.

  15. #15
    Join Date
    Jul 2002
    Location
    Romania
    Posts
    122
    I think you're on the wrong track...
    A combo box in Access does not have the AddItem method as in VB.
    But...
    Set the LimitToList property to True.
    Use the NotInList event to detect a missing item

    Response = acDataErrAdded

    and you're set.

    HTH

Posting Permissions

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