G
Guest
Help! I'm going around in circles in this one. Its apparent I'm missing
something about how VBA handles if/then/else statements. Debugging it shows
that always performing the "otherwise" code even if it already populated it
with the plastic field. WHICH I WOULD EXPECT since there is no ELSE statement
there, but if I put it in (right before the "otherwise" code, then its
pertaining to the first IF? [because then if CatalogRef isNot blank, it
populates it anyway] I don't understand why another END IF isn't required and
the one I have there - I have two IF's. Also, I have tried Else IF and Else -
and it didnt like that either: It either flat out wouldnt let me enter it or
I got the wrong results. Can anyone give me some pointers on how to correctly
write this? THANKS....
'If CatalogRef already has a value, dont bother with this
If (IsNull(.Fields("CatalogRef"))) Then
'If the metals field is blank, we'll use plastic
If (IsNull(.Fields("Metal"))) Then .Fields("CatalogRef") =
..Fields("Plastic") & " / " & .Fields("Lens")
'otherwise use the metal
.Fields("CatalogRef") = .Fields("Metal") & " / " & .Fields("Lens")
End If
something about how VBA handles if/then/else statements. Debugging it shows
that always performing the "otherwise" code even if it already populated it
with the plastic field. WHICH I WOULD EXPECT since there is no ELSE statement
there, but if I put it in (right before the "otherwise" code, then its
pertaining to the first IF? [because then if CatalogRef isNot blank, it
populates it anyway] I don't understand why another END IF isn't required and
the one I have there - I have two IF's. Also, I have tried Else IF and Else -
and it didnt like that either: It either flat out wouldnt let me enter it or
I got the wrong results. Can anyone give me some pointers on how to correctly
write this? THANKS....
'If CatalogRef already has a value, dont bother with this
If (IsNull(.Fields("CatalogRef"))) Then
'If the metals field is blank, we'll use plastic
If (IsNull(.Fields("Metal"))) Then .Fields("CatalogRef") =
..Fields("Plastic") & " / " & .Fields("Lens")
'otherwise use the metal
.Fields("CatalogRef") = .Fields("Metal") & " / " & .Fields("Lens")
End If