views:

879

answers:

3

Ok so could anyone please help me out with the VB for auto entering information into a text box, by clicking certian label boxes on a form in access 2003.

I built this thing using label boxes as "sort of links" instead of button for navigation/commands etc, and I have this power point presentation viewer on one of the forms.
The client has numerous briefings and this will be great for me to provide a little something for them to be able to get their briefings from one spot.

So if I list the choices for the month out on the form as label boxes (with little mouse move events to resemble a web link) and they click on it to select, then the only way I know how this may become functional is if I add a text box to the form, and make it not visible, that way I can name it, and add it to the file path string and it works.

But how do I create the action of clicking the "link" result in "NVOWEFDJHF" into text box?

Anyone know a better way?
Yeah I am an amateur, so I am ALWAYS willing to learn a better way.

Thanks very much!

+1  A: 

Quick air code here...

Private Sub MyLabel_OnClick()

  Me.MyTextBox = "NVOWEGDJHF"

End Sub

Don't forget your error handling.

David Walker
Maybe you should check your answers before posting them -- labels have no events.
David-W-Fenton
Labels absolutely DO have events, the On Click and the On Dbl Click.Only when a label is associated with a control does it lose it's event properties.My answer is completely correct in the OP's context. Please, feel free to check for yourself.
David Walker
A: 

You're making this as difficult as possible by using an approach that is not Access-native. The simplest way to make the labels "clickable" is to put a transparent command button over them. But that means the MouseMove events will go to the command button, so you'll have to have its events do the MouseOver actions.

David-W-Fenton
+2  A: 

I would recommend using a transparent button instead of a label.

The main reason is that you can set the mouse cursor to become a small hand when you hover over the button, so it gives back information to the user that this can be clicked.
With a label, the user cannot make the difference between a normal label and one that can be clicked since there is no visual cue.

To create a button that resemble a label:

  • Add the button to the form
  • In the properties for the button, set the following:
    • Format > Back-Style: Transparent
    • Other > Cursor on Hover: Hyperlink Hand
    • Other > Name: btAutoFill (or whatever name you want)
  • If you want the button to resemble a link a bit more, you can change it's caption's format, making it blue and underlined if you wish.

Now if you view the form, you will see that the mouse cursor will change when you move over the 'button label'.

To automatically fill-in other controls when you click your button, add the code to handle its OnClick event (in the button's properties, under Events > On Click, choose [Event Procedure]):

Public Sub btAutoFill_Click()
    myTextBox = "NVOWEFDJHF"
End Sub
Renaud Bompuis