The code below worked fine on a TAB form for a record with 16 characteristics. They changed the number of charactersitices to 50 so I wanted to use a subform so the other TAB formating would not be affected.
The problem is with the statement "Me(MCharF).Value = MCCF"
which sets the value of controls CC1 - CC50 as it goes through the procedure. I get an "Cannot find field" error message.
MCharF = "Forms![frmProductAuditA]![SOFChar].Form![CC1]" when the error message appears.
Private Sub SubcboCC() ' New procedure 1/13/05
Dim MCC, MCharF As String, Mcount As Integer, MCCF, MChar, MDobsF As String, MPobs As Variant, MPobsF As Variant, MDobs As Variant, MDobFs As Variant
MCC = "CC"
MPobs = "ProdObs"
MDobs = "DefcObs"
MChar = "CC"
Mcount = 1
MCCF = MCC & Mcount
MPobsF = "Forms![frmProductAuditA]![SOFChar].Form!" & "[" & MPobs & Mcount & "]"
MDobsF = "Forms![frmProductAuditA]![SOFChar].Form!" & "[" & MDobs & Mcount & "]"
MCharF = "Forms![frmProductAuditA]![SOFChar].Form!" & "[" & MChar & Mcount & "]"
Do While Mcount < 51
MCCF = DLookup(MCCF, "Partno", "[PartNo] = Forms!frmProductAuditA!cboPartNumber")
Me(MCharF).Value = MCCF
If MCCF Then
Me(MPobsF).BackColor = 52479
Me(MDobsF).BackColor = 52479
Else
Me(MPobsF).BackColor = 16777215
Me(MDobsF).BackColor = 16777215
End If
Mcount = Mcount + 1 'Increase Mcount by 1 for next loop
MCCF = MCC & Mcount 'Likewise, change field to CC2 etc
MPobsF = MPobs & Mcount
MDobsF = MDobs & Mcount
MCharF = MChar & Mcount
Loop 'Start routine all over
End Sub
The problem is with the statement "Me(MCharF).Value = MCCF"
which sets the value of controls CC1 - CC50 as it goes through the procedure. I get an "Cannot find field" error message.
MCharF = "Forms![frmProductAuditA]![SOFChar].Form![CC1]" when the error message appears.
Private Sub SubcboCC() ' New procedure 1/13/05
Dim MCC, MCharF As String, Mcount As Integer, MCCF, MChar, MDobsF As String, MPobs As Variant, MPobsF As Variant, MDobs As Variant, MDobFs As Variant
MCC = "CC"
MPobs = "ProdObs"
MDobs = "DefcObs"
MChar = "CC"
Mcount = 1
MCCF = MCC & Mcount
MPobsF = "Forms![frmProductAuditA]![SOFChar].Form!" & "[" & MPobs & Mcount & "]"
MDobsF = "Forms![frmProductAuditA]![SOFChar].Form!" & "[" & MDobs & Mcount & "]"
MCharF = "Forms![frmProductAuditA]![SOFChar].Form!" & "[" & MChar & Mcount & "]"
Do While Mcount < 51
MCCF = DLookup(MCCF, "Partno", "[PartNo] = Forms!frmProductAuditA!cboPartNumber")
Me(MCharF).Value = MCCF
If MCCF Then
Me(MPobsF).BackColor = 52479
Me(MDobsF).BackColor = 52479
Else
Me(MPobsF).BackColor = 16777215
Me(MDobsF).BackColor = 16777215
End If
Mcount = Mcount + 1 'Increase Mcount by 1 for next loop
MCCF = MCC & Mcount 'Likewise, change field to CC2 etc
MPobsF = MPobs & Mcount
MDobsF = MDobs & Mcount
MCharF = MChar & Mcount
Loop 'Start routine all over
End Sub