Results 1 to 6 of 6
  1. #1
    Access_Novice is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2013
    Posts
    265

    Requery Textbox after making selection from combo box

    I have a combo box called "className" and a textbox called "tuition." After I make a selection from the combo box, I want the textbox to requery the record source (which is a query) so that the value of tuition will be the proper value depending on what is selected from the combo box.



    I am not getting an error. The textbox just doesn't update at all. Here is my code:

    Code:
    Private Sub className_AfterUpdate()
        Me.tuition.Requery
    End Sub
    What am I doing wrong?

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Just a little side note. The combobox's Control Source property can be assisgned to a field within the recordset. This will cause the assigned field to be updated with the value of the bound column of the combobox. Now back to your question.

    Save your record and then requery your textbox.

    Private Sub className_AfterUpdate()

    if me.dirty = true then
    me.dirty = false
    end if

    Me.tuition.Requery
    End Sub

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Oops, I should have read Help closer... so I edited this..

    This is how I would update the text box

    If the tuition value is in the row source of the combo box, you can use the after update event of the combo box to update the text box.

    If the tuition value is in the 3rd column of the combo box row source, then you could use
    Code:
    Private Sub className_AfterUpdate()
        Me.tuition = Me.className_AfterUpdate.Column(2)
    End Sub
    (Combo box is zero based so 0 it the first column... 2 is the 3rd column)

  4. #4
    Access_Novice is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2013
    Posts
    265

    Still confused about how to update a text box after combo box selection

    Quote Originally Posted by ssanfu View Post
    Oops, I should have read Help closer... so I edited this..

    This is how I would update the text box

    If the tuition value is in the row source of the combo box, you can use the after update event of the combo box to update the text box.

    If the tuition value is in the 3rd column of the combo box row source, then you could use
    Code:
    Private Sub className_AfterUpdate()
        Me.tuition = Me.className_AfterUpdate.Column(2)
    End Sub
    (Combo box is zero based so 0 it the first column... 2 is the 3rd column)
    I'm confused. I have the database attached. I am on the form called 'frmMembership' which is based on the query called 'qryMembership.' The Row source for the combo box is a simple query of the table called 'Class.'
    Attached Files Attached Files

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    What purpose does 'frmMembership' serve? Couldn't a member enroll in more than one class?

  6. #6
    Access_Novice is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2013
    Posts
    265
    Quote Originally Posted by ItsMe View Post
    What purpose does 'frmMembership' serve? Couldn't a member enroll in more than one class?
    No. Each gymnast would be enrolled in only one class at a time.

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

Similar Threads

  1. Combo Box Will Not Requery
    By clchapin in forum Programming
    Replies: 3
    Last Post: 08-01-2013, 08:51 AM
  2. textBox Value making label visible
    By barkly in forum Forms
    Replies: 5
    Last Post: 07-24-2013, 07:05 PM
  3. Replies: 2
    Last Post: 06-03-2013, 11:52 AM
  4. Replies: 1
    Last Post: 03-13-2011, 02:29 PM
  5. Replies: 2
    Last Post: 09-17-2010, 09:53 AM

Tags for this Thread

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