I'm sure this can be done just don't know how.
On a form I have 4 combo boxes:
[Player1]
[Player2]
[Player3]
[Player4]
And 4 text boxes:
[Player1 Details]
[Player2 Details]
[Player3 Details]
[Player4 Details]
For each combo box I have an Update event which does a Dlookup which sends its result to its corresponding Details text box. For example:
OK....so each of my combo boxes has an afterupdate event which works fine. I want to now change my code so that I don't have to explicitly refer to the text boxes ([Player? Details]) and keep the Dlookup line exactly the same for each field event. I was thinking that I could use the Name of the combo box that is currently active and append the word "Details" on the end, which would in hand give me the name of the text box.
So Instead of:
[Player1 Details] = Dlookup("
On a form I have 4 combo boxes:
[Player1]
[Player2]
[Player3]
[Player4]
And 4 text boxes:
[Player1 Details]
[Player2 Details]
[Player3 Details]
[Player4 Details]
For each combo box I have an Update event which does a Dlookup which sends its result to its corresponding Details text box. For example:
Code:
Sub Player1_AfterUpdate()
[Player1 Details] = Dlookup("[code]","PlayerDetails", "[Player] = " & Me.ActiveControl)
End Sub
OK....so each of my combo boxes has an afterupdate event which works fine. I want to now change my code so that I don't have to explicitly refer to the text boxes ([Player? Details]) and keep the Dlookup line exactly the same for each field event. I was thinking that I could use the Name of the combo box that is currently active and append the word "Details" on the end, which would in hand give me the name of the text box.
So Instead of:
[Player1 Details] = Dlookup("
Code:
","PlayerDetails", "[Player] = " & Me.ActiveControl)[/b]
it would now look something like this (I know it doesn't work!):
[b]"[" & Me.Activecontrol.Name & " Details]" = Dlookup("[code]","PlayerDetails", "[Player] = " & Me.ActiveControl)[/b]
I hope I've explained things well enough and thanks to anyone that can help
[yinyang]
Shann