Dear forum,
i have the below code working on a user form whereby it blanks out certain fields when, in this instance "Paris" is selected. it works fine, however i wish to extend the functionality to work when other places are selected in the same way. ie if "Lille" were selected from the same me.port field instead of "Paris" and so on for a number of selections.
I have tried copying down for the other locations in the Private sub but this does not work.
should there be an If else function or something
Regards in advance
Paul
i have the below code working on a user form whereby it blanks out certain fields when, in this instance "Paris" is selected. it works fine, however i wish to extend the functionality to work when other places are selected in the same way. ie if "Lille" were selected from the same me.port field instead of "Paris" and so on for a number of selections.
I have tried copying down for the other locations in the Private sub but this does not work.
should there be an If else function or something
Regards in advance
Paul
VBA Code:
Private Sub Port_Change()
'blanks out vehicle fields for train ports
'Paris
With Me.nam3
.BackColor = IIf(Me.Port.Text = "Paris", vbRed, &HC0FFFF)
.Locked = CBool(.BackColor = vbRed)
.Text = IIf(.Locked, "N/A", "")
End With
With Me.Add
.BackColor = IIf(Me.Port.Text = "Paris", vbRed, &HC0FFFF)
.Locked = CBool(.BackColor = vbRed)
.Text = IIf(.Locked, "N/A", "")
End With
With Me.Veh
.BackColor = IIf(Me.Port.Text = "Paris", vbRed, &HC0FFFF)
.Locked = CBool(.BackColor = vbRed)
.Text = IIf(.Locked, "N/A", "")
End With
With Me.VRN
.BackColor = IIf(Me.Port.Text = "Paris", vbRed, &HC0FFFF)
.Locked = CBool(.BackColor = vbRed)
.Text = IIf(.Locked, "N/A", "")
End With
End Sub
Last edited by a moderator: