The Boondock Saint said:
Thanks for the advice Dirk,
Could you help me understand abit more about where this should go..
so that it happens as soon as the record loads...
You said Current Event, where about can i find this.... and Event
Procedure....
Thanks for your help..
The Saint
Here's how you do it. In these instructsions, I'm going to continue to
use "YourButtonName" and "Team1" as the names of the controls, but
you'll need to put the real names in.
Open the form in Design View.
Open the property sheet of the form (by clicking the Properties button
on the toolbar, or menu item View -> Properties).
Go to the Event tab on the property sheet. The first event property
listed is On Current. Double-click on the blank line beside the
property name.
If the line doesn't change to say "[Event Procedure]", click the
dropdown arrow that will have appeared at the right of the line, and
choose "[Event Procedure]" from the list.
Then click the "build" button -- caption "..." -- that appears to the
right of the dropdown arrow. The VB Editor window will open (separate
from the Access application window), with a window for the form's code
module inside it and the shell of an event procedure already created and
displayed for you. It will look like this:
Private Sub Form_Current()
End Sub
Change that procedure to look like this (subsitituting the appropriate
names):
Private Sub Form_Current()
Me!YourButtonName.Caption = Me!Team1
End Sub
That takes care of the form's Current event. We also need to create
procedure for the AfterUpdate event of the Team1 control.
Switch back to the Access application window. You don't need to close
the VB Editor window.
Looking at the form in design view, click on the "Team1" control. If
the property sheet is still open, it will automatically change from
displaying the form's property sheet to displaying the property sheet
for Team1. If the property sheet isn't open, open it.
On the Event tab of the property sheet, go down to the After Update
event property line (the second line from the top, I think). Follow a
similar procedure to the one you used for the On Current property, to
create and display an event procedure shell for this event. It will
look like this:
Private Sub Team1_AfterUpdate()
End Sub
Change that procedure to look like this (subsitituting the appropriate
names):
Private Sub Team1_AfterUpdate()
Me!YourButtonName.Caption = Me!Team1
End Sub
Having done that, close the module window, then click the Save button on
the toolbar of the VB Editor, and close the VB Editor. That should drop
you back in the regular Access application window. Close the form,
saving it if prompted to do so.
You're done. Try it and see if it works. If it doesn't, we've probably
got the names of the controls wrong.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)