Results 1 to 4 of 4
  1. #1
    rrum is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2010
    Posts
    5

    Populating a combo box based on a text box

    I have been using an After Update VBA code that is supposed to work for cascading combo boxes, but I do not know if this is what I am supposed to be using for populating a combo box in a subform based on a text box in the main form, or if this is even possible. What I have in the main form is an unbound combo box with a filter command, which lists "clients" based on a client ID. Based on the client ID, the main form is populated by "category" records (several categories for each client). The Category ID is displayed within a text box. I have two subforms that relate to the category ID, which I would like to input records based on the category ID. Each subform has a combo box that I want to select records based on the categoryID of the textbox (I only want to display records from the lookup table that relate to the displayed category ID). Does this make sense? I used this code for the After Update of the text box: Me.cboREQuant.RowSource = "SELECT tblRiskExpQuant.REQuantID, tblRiskExpQuant.Risk_Exposure, tblRiskExpQuant.RiskCatID FROM tblRiskExpQuant WHERE tblRiskExpQuant.RiskCatID=" & Me.txtRiskCatID & " ORDER BY tblRiskExpQuant.Risk_Exposure" where cboREQuant is the combo box in the subform. The drop-down box in the combo box of the subform is just blank - it will not show any records, even though a query based on these components runs just fine.

  2. #2
    jzwp11 is offline VIP
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Since the combo box is a control in the subform, you have to reference it differently if the code fires from the main form. The appropriate syntax is as follows:

    Me.subformcontrolname.form!cboREQuant.RowSource = "SELECT..."

    Check out this site for more on referencing controls and properities

  3. #3
    rrum is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2010
    Posts
    5
    Thank you!

  4. #4
    jzwp11 is offline VIP
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You're welcome. Good luck with your project.

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

Similar Threads

  1. Replies: 2
    Last Post: 05-05-2010, 02:52 PM
  2. Populating a "Text" field in a Report
    By two_smooth in forum Reports
    Replies: 20
    Last Post: 02-19-2010, 11:25 AM
  3. Replies: 1
    Last Post: 08-26-2009, 10:45 AM
  4. Populating other fields from combo box.
    By nkenney in forum Forms
    Replies: 1
    Last Post: 05-14-2009, 10:39 PM
  5. Calculated Text Box Populating in Table
    By Debbie in forum Access
    Replies: 2
    Last Post: 11-13-2006, 08:02 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