My Assistant
![]()
Custom Search
|
![]() ![]() |
![]() |
![]() Post#1 | |
Posts: 150 Joined: 11-June 04 ![]() | Have a form with two combo boxes. The first combo box is named cboVehicleMake which pulls its values from the tblVehicleMakes table and is bound to the Make field in the table. The second combo box is named cboVehicleModel and it pulls its values from a query, which pulls its values from tblVehicleModels but in the criteria field for the query, I have the following: [Forms]![frmAddNewUnit]![cboVehicleMake] Then on the AfterUpdate event for the cboVehicleMake combo box, I have the following code: Private Sub cboVehicleMake_AfterUpdate() cboVehicleModel.Requery End Sub The idea behind this is to synchronize the second combo box based on the value of the first, but after updating the first combo box, the values on the second one are blank. THere is the SQL on the query for the cboVehicleModels combo box: SELECT tblVehicleModels.VehicleMake, tblVehicleModels.VehicleModel FROM tblVehicleModels WHERE (((tblVehicleModels.VehicleMake)=[Forms]![frmAddNewUnit]![cboVehicleMake])); Thanks in advance for your help. |
![]() Post#2 | |
![]() UdderAccess Admin + UA Ruler Posts: 19,557 Joined: 27-April 02 From: Upper MI ![]() | A detailed explanation of such a combobox arrangement is found in the Cascading Combo Boxes article in the UA Wiki. You just need to be sure which column of the previous combobox is being evaluated. hope this helps ![]() |
![]() Post#3 | |
Posts: 2 Joined: 31-July 14 ![]() | I have a similar problem. Combo box named TableSelect (Combo1) lists tables from T_tables Combo box named Combo31 (Combo2) is supposed to list attributes from T_attributes that relate to the table selected in Combo1. Ocopied/edited the code from the wiki examples - simple one. The Row Source for Combo2 is updating with the SQL string updated by the AfterUpdate. However, I see only one blank row in Combo2. I checked the tables and there should be anywhere from 5-25 attributes returned for a table selected in Combo1. Your comment about referencing the right column - The bound column for Combo1 is the TableID, which is what I am looking for, I think. Can you steer me in a direction to solve this? My code is below: ========================= Private Sub TableSelect_AfterUpdate() Dim strSQL As String strSQL = "SELECT T_attributes.AttribID, T_attributes.Attribute " & _ "FROM T_attributes WHERE (((T_attributes.TableID=" & Me.TableSelect.Value & ")) ORDER BY T_attributes.AttribID;" Me.AttribSelect.RowSource = strSQL Me.Combo31.Requery Me.Combo31.SetFocus Me.Combo31.Dropdown End Sub |
![]() Post#4 | |
Posts: 2 Joined: 31-July 14 ![]() | Scratch that particular query. I had the wrong field name referenced.When I changed that it worked. Then I saved the form, moved some things around on it, opened the form again and the table select box won't accept any entry |
![]()
Custom Search
|
![]() | Search Top Lo-Fi | 12th December 2019 - 12:49 AM |