Results 1 to 6 of 6
  1. #1
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    Brookings, South Dakota, USA
    Posts
    449
    Thanks
    0
    Thanked 0 Times in 0 Posts

    RecordSource populate Combo RowSource? (A2k, SP2, DAO)

    Hi All,
    Is it possible to use the RecordSource (using the RecordsetClone) of a Form to populate the RowSource of a ComboBox (which is on a PopForm opened from the Form in question)? If so how?
    <IMG SRC=http://www.wopr.com/w3tuserpics/gdrezek_sig.jpg>
    "Those who dance are considered insane by those who can't hear the music" - George Carlin

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: RecordSource populate Combo RowSource? (A2k, SP2, DAO)

    You wrote:
    >>Is it possible to use the RecordSource (using the RecordsetClone) of a Form to populate the RowSource of a ComboBox (which is on a PopForm opened from the Form in question)? If so how?<<

    I don't think so, since the rowsource property is a string, and expects a table/query name or an SQL string. You could do this, I suppose:

    cbo.RowSource = Me.Recordsource
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    Brookings, South Dakota, USA
    Posts
    449
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: RecordSource populate Combo RowSource? (A2k, SP2, DAO)

    Hi Marty and Thank You,
    I wasn't able to do this directly, but what I did does work. In the OnOpen event of the PopForm I created tblTemp. Then followed that code with the following:

    Dim rst As Recordset
    Dim rst2 As Recordset

    Set rst = Forms!frmCourseInformation.RecordsetClone
    Set rst2 = db.OpenRecordset("tblTemp")
    With rst
    Do Until .EOF
    rst2.AddNew
    rst2!CoursePKID = !CoursePKID
    rst2!Title = !Title
    rst2.Update
    .MoveNext
    Loop
    End With

    Me.cboFindCourse.RowSourceType = "Table/Query"
    Me.cboFindCourse.RowSource = "tblTemp"

    Set rst = Nothing
    Set rst2 = Nothing

    In the OnClose event of the PopForm I delete tblTemp.
    I like to use popup forms for search and goto comboboxes. Now I don't have to worry about the RowSource criteria of the Search/GoTo combobox on a form with a RecordSource that is changeable at the click of a button.
    Thank you for your time and help.

    gdr
    <IMG SRC=http://www.wopr.com/w3tuserpics/gdrezek_sig.jpg>
    "Those who dance are considered insane by those who can't hear the music" - George Carlin

  4. #4
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    Brookings, South Dakota, USA
    Posts
    449
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: RecordSource populate Combo RowSource? (A2k, SP2, DAO)

    Hi Marty,
    btw, I needed to add .MoveLast then .MoveFirst; i.e.

    With rst
    .MoveLast
    .MoveFirst
    Do Until .EOF

    otherwise the combobox filled with only the records *after* the record choice to go to.

    gdr
    <IMG SRC=http://www.wopr.com/w3tuserpics/gdrezek_sig.jpg>
    "Those who dance are considered insane by those who can't hear the music" - George Carlin

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: RecordSource populate Combo RowSource? (A2k, SP2, DAO)

    Why are you moving last and first in this? Usually, you movelast in a DAO recordset in order to get an accurate recordcount. If you just want to get back to the first record in the recordset, do something like this:

    If Not rst.BOF Then
    rst.MoveFirst
    End If
    Charlotte

  6. #6
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    Brookings, South Dakota, USA
    Posts
    449
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: RecordSource populate Combo RowSource? (A2k, SP2, DAO)

    Hi Charlotte and Thank You,
    Yep, that's all I wanted to do, just trying to ensure that the combobox filled with all the records.
    Thanks for the tip.

    gdr
    <IMG SRC=http://www.wopr.com/w3tuserpics/gdrezek_sig.jpg>
    "Those who dance are considered insane by those who can't hear the music" - George Carlin

Posting Permissions

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