I am looking for ideas on how to condense my code that I have on making certain fields and lines visible on a form depending on certain data that I need to display.
This is a type of a scalable form that changes width (with columns) and certain headings depending on what the form needs to hold but there must be a more compact way of doing this...
In the following code, I have several sections of similar code (7 in all) where the control names are changed to only affect the controls of interest.
In other areas of my code where I have similarly duplicate sections of code I have been able to create substitution variable that work well for loading fields in tables such as:
But I am not sure if this substitution method can be done with controls in the code below:
Is there a way to create substitution variables for the above code to set the attributes of the controls?
Or any other ideas how I might condense my code in an effiecent manner?
Please advise
Thanks!
This is a type of a scalable form that changes width (with columns) and certain headings depending on what the form needs to hold but there must be a more compact way of doing this...
In the following code, I have several sections of similar code (7 in all) where the control names are changed to only affect the controls of interest.
In other areas of my code where I have similarly duplicate sections of code I have been able to create substitution variable that work well for loading fields in tables such as:
ThisOP = "Operation" & CurOp ' determine if this is an inspection (last) step
NextOP = "Operation" & CurOp + 1 ' determine if this is an inspection (last) step
OpEnd = "OP" & CurOp & "End" ' set for the correct end date for this operation
EID = "EID" & CurOp
If objrs(NextOP) = "end" Then objrs("CurrentOp") = "record almost complete"
If objrs(ThisOP) = "" Then objrs("CurrentOp") = "record complete"
objrs(EID) = Me.opinit
But I am not sure if this substitution method can be done with controls in the code below:
If Me.OP7 = "" Then
OP7.Visible = False
op7init.Visible = False
Op7date.Visible = False
op7ldate.Visible = False
op7linit.Visible = False
O7line.Visible = False
O7bline.Visible = False
op7head.Visible = False
op7box.Visible = False
system7.Visible = False
Else
OP7.Visible = True
op7init.Visible = True
op7linit.Visible = True
Op7date.Visible = True
op7ldate.Visible = True
O7line.Visible = True
O7bline.Visible = True
op7head.Visible = True
op7box.Visible = True
system7.Visible = False
If Me.OP7 = str Then
O7line.Visible = False
O7bline.Visible = False
system7.Visible = True
op7ldate.Visible = False
op7linit.Visible = False
End If
End If
Is there a way to create substitution variables for the above code to set the attributes of the controls?
Or any other ideas how I might condense my code in an effiecent manner?
Please advise
Thanks!