Snowflake68
Registered User.
- Local time
- Today, 09:08
- Joined
- May 28, 2014
- Messages
- 464
This relates to a previously solved post but I have since had to make changes to the system which has inadvertently stopped things working how I need them.
This is the old post for reference.
https://www.access-programmers.co.uk/forums/showthread.php?t=298051
So, I have several cascading combo boxes which are bound to fields in my main table. The first combo box the user selects a value and then the second combo box filters the list based upon the value selected in the first combo box.
I have a function that then checks to see if the selected value in the second combo box still exists if the value in the first combo box changes. If the value is no longer valid then the combo box backcolour is formatted to red and retains the text value.
This is the function that is called on the after update even of the combo boxes.
The above all works perfectly but here is my problem now.
I have now changed the combo boxes to 2 columns and bound the first one (which is the code rather than the description) The first column I have set to being not visible in the list (column widths 0cm,5cm) as I only want to display the description and since doing so it is not retaining the text value when the back colour changes indicating an invalid selection.
The function doesn't error and is working fine as far as formatting the back colour but I need help to figure how to retain the text value which is what it was doing previously when it was only the single column in the combo box.
I have cut down my application (attached) just to demonstrate the issue I have.
When you open up the app click on the 'Edit Quote' tab. The department is set at 'Mens' and the 'Type' is set to 'Hoody'. Now change the Department from 'Mens' to 'Boys'.
You will see that the 'Type' combo box back colour will change to red but he text value of 'Hoody' appears to disappear. I want to keep the text value so that the user can remember what they previously selected. I say appears to disappear because the code for 'Hoody' is still actually stored in the table. If you change the Department back to Mens then 'Hoody' reappears.
Hope someone can figure out why this is doing this. I suspect its something to do with the bound column against what is displayed but I just cant figure out what I need to change in the function.
Thanks for looking.
This is the old post for reference.
https://www.access-programmers.co.uk/forums/showthread.php?t=298051
So, I have several cascading combo boxes which are bound to fields in my main table. The first combo box the user selects a value and then the second combo box filters the list based upon the value selected in the first combo box.
I have a function that then checks to see if the selected value in the second combo box still exists if the value in the first combo box changes. If the value is no longer valid then the combo box backcolour is formatted to red and retains the text value.
This is the function that is called on the after update even of the combo boxes.
Code:
Public Function CheckValues(intTest As Integer)
Dim ctl As Control
Dim i As Integer
Dim bolFlag As Boolean
For Each ctl In Me
bolFlag = True
If ctl.Tag = "A" Then
ctl.Requery
ctl.BackColor = RGB(222, 235, 247)
For i = 0 To ctl.ListCount
If (ctl.ItemData(i) = ctl.Value) Or (Nz(ctl.Value, "") = "") Then bolFlag = False
Next
If bolFlag Then
' ctl = "" 'reset to Null
ctl.BackColor = RGB(250, 190, 190) ' change backcolour to red in not in list
End If
End If
Next ctl
End Function
The above all works perfectly but here is my problem now.
I have now changed the combo boxes to 2 columns and bound the first one (which is the code rather than the description) The first column I have set to being not visible in the list (column widths 0cm,5cm) as I only want to display the description and since doing so it is not retaining the text value when the back colour changes indicating an invalid selection.
The function doesn't error and is working fine as far as formatting the back colour but I need help to figure how to retain the text value which is what it was doing previously when it was only the single column in the combo box.
I have cut down my application (attached) just to demonstrate the issue I have.
When you open up the app click on the 'Edit Quote' tab. The department is set at 'Mens' and the 'Type' is set to 'Hoody'. Now change the Department from 'Mens' to 'Boys'.
You will see that the 'Type' combo box back colour will change to red but he text value of 'Hoody' appears to disappear. I want to keep the text value so that the user can remember what they previously selected. I say appears to disappear because the code for 'Hoody' is still actually stored in the table. If you change the Department back to Mens then 'Hoody' reappears.
Hope someone can figure out why this is doing this. I suspect its something to do with the bound column against what is displayed but I just cant figure out what I need to change in the function.
Thanks for looking.