noisepoet
Board Regular
- Joined
- Oct 19, 2006
- Messages
- 87
The code below is a combo box Event Procedure. When I select a fund number from the combo box, the vba compares the code against a table containing a series of fund categories that exist within different ranges of numbers and displays the corresponding fund category in a separate text box (e.g. Fund Category A has a numeric range of 100-200, so if I select fund number 123 on the combo box, my fund category text box should display "Fund Category A").
The "Else" statement below is meant to display "Not Assigned" in the fund category text box if a fund number is selected in the combo box that does not exist within any of the fund category numeric ranges. Unfortunately, it is overriding the preceding "If" logic, and "Not Assigned" is displaying as the category for every selection, regardless of whether or not it exists within an established numeric range. What am I doing wrong?
The "Else" statement below is meant to display "Not Assigned" in the fund category text box if a fund number is selected in the combo box that does not exist within any of the fund category numeric ranges. Unfortunately, it is overriding the preceding "If" logic, and "Not Assigned" is displaying as the category for every selection, regardless of whether or not it exists within an established numeric range. What am I doing wrong?
VBA Code:
' txtCategory based on cboFund_Number
Dim fundCategoryMap As DAO.Recordset
Set fundCategoryMap = CurrentDb.OpenRecordset("tblFund_Category_Map")
fundCategoryMap.MoveFirst
Do While Not fundCategoryMap.EOF
If (Me.cboFundNumber.Value >= fundCategoryMap.Fields("FromRange")) And _
(Me.cboFundNumber.Value <= fundCategoryMap.Fields("ToRange")) Then
Me.txtCategory.Value = fundCategoryMap.Fields("Category")
Else
Me.txtCategory.Value = "Not Assigned"
End If
fundCategorytMap.MoveNext
Loop