Results 1 to 2 of 2
  1. #1
    fleschnj is offline Novice
    Windows XP Access 2007
    Join Date
    Nov 2010
    Posts
    1

    Update a text box based on a combo box

    Hello almighty Access Gurus.

    I'm in a bit of a tough spot and the solution to this problem has just been eluding me for over a week. I'm hoping someone can help me.

    On a form, I have two combo boxes. They are called cbotopics and cbosources. I have what appears in cbosources limited by what is selected in cbotopics. I am using this visual basic code to do it.



    Private Sub cbotopics_AfterUpdate()

    Me.cbosources.RowSource = "SELECT source FROM" & _
    " SourceNotes WHERE topic = " & Me.cbotopics & _
    " ORDER BY Source"
    Me.cbosources = Me.cbosources.ItemData(0)

    End Sub
    Now below those two combo boxes, I have a text box. (tbnotes)

    I would like tbnotes to display information based on what is selected in cbosources.

    How? I've tried to do some VB code like this:
    Private Sub cbosources_AfterUpdate()

    Me.tbnotes.RowSource = "SELECT notes FROM" & _
    " SourceNotes WHERE source = " & Me.cbosources & _
    " ORDER BY Source"
    Me.tbnotes = Me.cbosources.ItemData(0)

    End Sub
    but I keep receiving errors.

    Help!

    P.S I have all the needed information setup in a table called SourceNotes.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    A textbox doesn't have a row source property, and you can't set its control source to SQL. You could use a DLookup() to place the value in the textbox. If there will be multiple values, it needs to be a combo or list box so you can set the row source property.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 15
    Last Post: 09-18-2010, 01:19 PM
  2. Replies: 3
    Last Post: 06-29-2010, 12:08 PM
  3. Replies: 2
    Last Post: 05-05-2010, 02:52 PM
  4. Replies: 2
    Last Post: 03-03-2010, 07:37 AM
  5. Replies: 1
    Last Post: 08-26-2009, 10:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums