UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Cascading Combo Box--cannot Select Value, Access 2013    
 
   
ScottyBee
post Sep 20 2019, 04:36 PM
Post#1



Posts: 50
Joined: 6-June 05
From: Portland Oregon


Hello, I have a combo box named cboBuildings where I can select the building of my choice. I have an After Update event attached to this control and the code is:

CODE
Private Sub cboBuilding_AfterUpdate()
Me.cboSystem.RowSource = "Select fk_BuildingID, SystemName " & _
                             "From Systems " & _
                             "Where fk_BuildingID = " & Nz(Me.cboBuilding.Value) & _
                             " Order by SystemName"
    
End Sub


I have a second combo box namded cboSystem that draws upon the value chosen in the cboBuilding. When I click the drop down, all three Systems appear but I cannot select a value. One of the systems is highlighted but when I debug, the value of this field in NULL.

I have checked the properties of the combo box and Enabled is Yes and Allow Edits is yes. Any ideas on why I cannot select a value?

By the way, these cascading combo boxes are only going to be used for navigation, not for any edits to the database. Thanks
Go to the top of the page
 
RJD
post Sep 20 2019, 04:57 PM
Post#2


UtterAccess VIP
Posts: 10,080
Joined: 25-October 10
From: Gulf South USA


Hi Scotty: Could you post the db (or a cut-down of it with relevant objects and test data), zipped? Since you have indicated "cascading combobox," seeing how you have set this up would be very revealing. There is always an answer, but seeing the db should reveal that answer quickly.

Are the comboboxes unbound, as they should be when used for navigation?

HTH
Joe

--------------------
"Each problem that I solved became a rule, which served afterwards to solve other problems."
"You just keep pushing. You just keep pushing. I made every mistake that could be made. But I just kept pushing."

Rene Descartes 1596-1650 (Mathematician and Philosopher)
Go to the top of the page
 
ScottyBee
post Sep 20 2019, 05:46 PM
Post#3



Posts: 50
Joined: 6-June 05
From: Portland Oregon


Hello RJD, thanks for taking the time to look at the database further. I have attached it here:

Attached File  PostedDatabase.zip ( 624.81K )Number of downloads: 6


When you open the database, the default EER Form comes up. The combo boxes are in the top, right corner of the database. Select Building 120 as it has 3 Systems that are available.

Attached File  Combo_Box_Values.jpg ( 12.21K )Number of downloads: 0


When you click one of these 3 Systems, the value is not retained in the combo box. Once I get this figured out, then I want to select the SubSystem combo box that is based on the System combo box. I have an "After Update" event attached to the cboBuilding and cboSystem combo boxes.

As far as I can tell, the code is just fine but maybe you will spot something? Thanks again.
Go to the top of the page
 
RJD
post Sep 20 2019, 07:38 PM
Post#4


UtterAccess VIP
Posts: 10,080
Joined: 25-October 10
From: Gulf South USA


Hi again: Well, the code approach was a bit off. Take a look at my revision to your db. Test the three comboboxes. Then look at the three combobox properties. See the Row Sources and the AfterUpdate event procedures.

See if this works better for you.

HTH
Joe
Attached File(s)
Attached File  PostedDatabase_Rev1.zip ( 183.01K )Number of downloads: 5
 

--------------------
"Each problem that I solved became a rule, which served afterwards to solve other problems."
"You just keep pushing. You just keep pushing. I made every mistake that could be made. But I just kept pushing."

Rene Descartes 1596-1650 (Mathematician and Philosopher)
Go to the top of the page
 
ScottyBee
post Sep 20 2019, 08:26 PM
Post#5



Posts: 50
Joined: 6-June 05
From: Portland Oregon


That worked perfectly RJD, a big thanks! I had a second set of combo boxes below the ones you fixed where I tried the same approach as you but could not get it to work. I left out a field in the cboSystem2 control's rowsource that the cboSubSystem2 control needed so came up blank.

This was a classic case of going down the wrong "rabbit hole" when I initially was on the right track. Just curious though, why wouldn't the logic of populating another combo box's row source from the After Update event of another combo box work? Sounded logical from the Google search I did and example that followed but obviously didn't work.

Thanks again for your help. smile.gif
Go to the top of the page
 
RJD
post Sep 20 2019, 08:59 PM
Post#6


UtterAccess VIP
Posts: 10,080
Joined: 25-October 10
From: Gulf South USA


You are very welcome, Scotty. Glad that works for you.

I guess you could go the route of re-creating the row source, if done properly, but that is clearly the hard way. Making the row source code static, with ref to a combo box column in a WHERE clause, and re-querying it from the previous combobox is the easy and efficient way to do this.

Continued success with your project.

Regards,
Joe

--------------------
"Each problem that I solved became a rule, which served afterwards to solve other problems."
"You just keep pushing. You just keep pushing. I made every mistake that could be made. But I just kept pushing."

Rene Descartes 1596-1650 (Mathematician and Philosopher)
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    15th October 2019 - 09:56 AM