03Explorer
Technical User
Have a working loop that uses a variable name that is using the loop value (i) within the string name for populating. I am working on a nested second loop that sits within the first loop and need that loop value (r) to do data checking on specific values. The (i) loop is working wonderfully, but trying to get the 2nd loop (r) to work within is not appearing to be as easy.
The intent is to cycle through 5 records looking for where the value = 'None'. If it does exist, the loop blanks out three values.
The issue is MS Access does not like the (r) numeric value as a second dynamic change in a field name.
I hope this is a simple mistake or oversight.
Code:
Dim i As Integer 'loop counter for row tracking
Dim r As Integer 'loop counter for Skill Type checking (Rob)
For i = 1 To txtCountRows
' Set Row variables - note: the "(i)" is how we tell what row we are processing
tmp1R(i) = Forms![frmSurveysPreGenerate].Controls("cboSelectProjectRow" & (i)).Value
tmp2R(i) = Forms![frmSurveysPreGenerate].Controls("txtClientIDRow" & (i)).Value
tmp3R(i) = Forms![frmSurveysPreGenerate].Controls("cboSelectServiceTypeRow" & (i)).Value
tmp4R(i) = Forms![frmSurveysPreGenerate].Controls("cboSelectRoleRow" & (i)).Value
tmp5R(i) = Forms![frmSurveysPreGenerate].Controls("cboSelectSurveyor1Row" & (i)).Value
tmp6R(i) = Forms![frmSurveysPreGenerate].Controls("cboSelectSkillType1Row" & (i)).Value
tmp7R(i) = Forms![frmSurveysPreGenerate].Controls("cboSelectRole1Row" & (i)).Value
tmp8R(i) = Forms![frmSurveysPreGenerate].Controls("cboSelectSurveyor2Row" & (i)).Value
tmp9R(i) = Forms![frmSurveysPreGenerate].Controls("cboSelectSkillType2Row" & (i)).Value
tmp10R(i) = Forms![frmSurveysPreGenerate].Controls("cboSelectRole2Row" & (i)).Value
tmp11R(i) = Forms![frmSurveysPreGenerate].Controls("cboSelectSurveyor3Row" & (i)).Value
tmp12R(i) = Forms![frmSurveysPreGenerate].Controls("cboSelectSkillType3Row" & (i)).Value
tmp13R(i) = Forms![frmSurveysPreGenerate].Controls("cboSelectRole3Row" & (i)).Value
tmp14R(i) = Forms![frmSurveysPreGenerate].Controls("cboSelectSurveyor4Row" & (i)).Value
tmp15R(i) = Forms![frmSurveysPreGenerate].Controls("cboSelectSkillType4Row" & (i)).Value
tmp16R(i) = Forms![frmSurveysPreGenerate].Controls("cboSelectRole4Row" & (i)).Value
tmp17R(i) = Forms![frmSurveysPreGenerate].Controls("cboSelectSurveyor5Row" & (i)).Value
tmp18R(i) = Forms![frmSurveysPreGenerate].Controls("cboSelectSkillType5Row" & (i)).Value
tmp19R(i) = Forms![frmSurveysPreGenerate].Controls("cboSelectRole5Row" & (i)).Value
' Count how many parents were populated for each row (variable strParentPopulated)
DoCmd.SetWarnings False
' Walk through Skill Type, checking for values of 'None' so they do NOT get appended 20190925(Rob)
' 5 variables to check:
' tmp6R(i), tmp9R(i), tmp12R(i), tmp15R(i), tmp18R(i)
'
For r = 6 To 18 Step 3
If tmp(r)R(i) = "None" then
tmp(r-1)R(i) = ""
tmp(r)R(i) = ""
tmp(r+1)R(i) = ""
End If
Next r
Next i
The intent is to cycle through 5 records looking for where the value = 'None'. If it does exist, the loop blanks out three values.
The issue is MS Access does not like the (r) numeric value as a second dynamic change in a field name.
I hope this is a simple mistake or oversight.