I have a very simple question. Basically I have written a piece of code that loops through a field and identifies the numbers and depending on what the number is it sets it to one of the option1, option2 etc variables.
But when I run the code, I can't get the option variables to reset when it moves onto the next field. So if the first field contains the numbers 2,3 and 4 but the second only contains 2 and 3 it'll still display 2,3 and 4.
I have included my code below but please let me know if this doesn't make sense.
But when I run the code, I can't get the option variables to reset when it moves onto the next field. So if the first field contains the numbers 2,3 and 4 but the second only contains 2 and 3 it'll still display 2,3 and 4.
I have included my code below but please let me know if this doesn't make sense.
Code:
Public Sub HigherValue()
Dim option1, option2, option3, option4, option5 As Integer
option1 = 0
option2 = 0
option3 = 0
option4 = 0
option5 = 0
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim fld As Field
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT ComputerUse FROM tblTestData WHERE ComputerUse Like '(-5*'", dbOpenDynaset)
Do While Not rs.EOF
For Each fld In rs.Fields
For i = 1 To Len(fld)
If IsNumeric(Mid$(fld, i, 1)) Then tempValue = CInt(Mid$(fld, i, 1))
Select Case tempValue
Case 1: option1 = 1
Case 2: option2 = 2
Case 3: option3 = 3
Case 4: option4 = 4
Case 5: option5 = 5
End Select
Next
Debug.Print option1
Debug.Print option2
Debug.Print option3
Debug.Print option4
Debug.Print option5
Debug.Print " "
Next 'END FOR EACH
rs.MoveNext
Loop
End Sub