OK - here's the reasoning behind the code that I had written:
Quote:
|
quote:After the DownloadLocation field is updated with a new field value
|
Therefore, you need something attached to the After Update event.
You've got it on Form_Current - which means it only changes when you change records
In your Case statement, you're
technically changing the value of [DownloadLocation], but you're just changing it to what it already is, so the bit where you have [DownloadLocation] = "Kazaa Media Network", is totally redundant, because in order to change it to that, it has to be that already (eg: "if Field=A then Field=A" is completely pointless)
You also said that you wanted the text displayed NEXT to the field - in other words - not in the field itself, so I assumed you'd put it in a label.
So as a summary - this is what my code does:
When the field is updated, the value of the field is displayed next to it, in a colour which is based on the value of the field
and what your code does is:
When the current record changes, the new value of the text box is changed to be the same as what it already is, and the text is changed based on the value of the field.
A combination of the two codes (which is basically just my original one written as a Case statement rather than an If statement):
Code:
Private Sub DownloadLocation_AfterUpdate()
Select Case DownloadLocation
Case "Kazaa Media Network"
SomeLabel.Forecolor = vbRed
Case "GarageBandRecords"
SomeLabel.Forecolor = RGB (255, 45, 0)
Case Else
SomeLabel.Forcolor = vbWhite
End Select
SomeLabel.Caption = DownloadLocation
End Sub
While both codes will actually function, it's what they actually do that differs.
So, other than making the value of the field "change" unnecessarily, your code works fine. But the thing is - what exactly is it you want to do?
Do you want the colour of the text in the textbox to change?
or do you want the color of the text in something else to change?
Do you want this to fire when the record changes?
or do you want it to fire when the value of the textbox changes?
It's because of different answers to these questions that our code differs so much.
Steven
I am a loud man with a very large hat. This means I am in charge