Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2004
    Posts
    2

    Angry Unanswered: Setting Rowsource for a combo box in MS Access

    I am trying to do this in Access97. Here is my situation:
    I am connected to a DB1 database. I need to set a row source for a combobox from a different database(MSAccess). The combobox has 2 columns. The first one is Emp# and the 2nd is EmpName; If I use the ValueList type, I get the error "2176: Setting for the property is too long". Looks like I can have only upto 255 or 2048 chars depending on the data type. Does anybody know of a way to solve this? This is what I an doing:

    Set SCDB = DBEngine.OpenDatabase(SecondDB)
    Set SCRS = SCDB.OpenRecordset("SELECT ENo, EName FROM [EmpInfo] ORDER BY ENo")
    If Not SCRS.EOF Then
    EqStr = ""
    Do While Not SCRS.EOF
    EqStr = EqStr & SCRS!ENo & ";" & SCRS!EName & ";"
    SCRS.MoveNext
    Loop
    EQFrom.RowSource = EqStr
    End If


    For EqStr I get the values "1003;Aviala;1005;......" for the length of 20,000. Total # of recs are about 800. I think if I use Table/Query as the rowsource type I might be able do it, but again this will be coming from a different database, so I am not sure how to set up the rowsource.
    Any ideas?

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    please excuse my confusion, by why would you want thousands of character in a combo? (and how many of your employes have names that exceed 2048 characters?).

    anyway, assuming what you want to do makes sense to you, you can certainly try:

    dim strSQL as string
    strSQL = "SELECT ENo, EName FROM [EmpInfo] ORDER BY ENo;"
    mycombo.rowsource = strSQL

    (also adjusting .boundcolumn, .columncount, .columnwidths to suit)

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Looks like a candidate for the Join function ... Or use a table/query to bind the combobox to ...

  4. #4
    Join Date
    Jan 2004
    Posts
    2
    sorry if I was not clear.
    The total length of the EQStr (the rowsource) is > 2048 which is a valuelist seperated by ; for each col.
    I think my only solution would be to use a Table/Query but without linking/importing how would I set the rowsource <it is from a different db>? I tried doing
    strSQL = "SELECT ENo, EName FROM [EmpInfo] ORDER BY ENo;"
    mycombo.rowsource = strSQL
    but it looks for the EmpInof in the Currentdb. It is not present in the currentdb.

  5. #5
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Sue,

    Check out this thread: http://www.dbforums.com/t977416.html

    It should be enlightening for you ...

Posting Permissions

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