Buttons, as links.

User avatar
Steve_in_Kent
4StarLounger
Posts: 421
Joined: 04 Feb 2010, 11:46

Buttons, as links.

Post by Steve_in_Kent »

I have a button in a form. the onclick of the button is set to:-
Application.FollowHyperlink Me.Link

Which when clicked follows a text box hyperlink, to open a document.

however, i also need the caption of each of the buttons to display some different text.
On the forms 'on activate' event, i''ve tried to put this code:-

Form.MainTab.Pages(0).BigButton.Caption = Me.[Document Link]

But its not finding the button.
The form is on a tab (the first one).
[Document Link] is the text i want displayed on each button.

So, i'm guessing my format is wrong to address the button. and ofc, i'm not even sure this will work ?
----------------------------------------------------------------------------------------
Owing at LEAST 34 beers to other helpful forum members. Especially HansV!

User avatar
HansV
Administrator
Posts: 78591
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Buttons, as links.

Post by HansV »

I think you should be able to use

Me.BigButton.Caption = Me.[Document Link]

If Document Link is a bound control, you may want to update the caption in the On Current event of the form.
Best wishes,
Hans

User avatar
Steve_in_Kent
4StarLounger
Posts: 421
Joined: 04 Feb 2010, 11:46

Re: Buttons, as links.

Post by Steve_in_Kent »

Yea, that was the first thing i tried hans.. but it came up with data member not found. hence why i went a bit more in depth and tried to reference the tab.
----------------------------------------------------------------------------------------
Owing at LEAST 34 beers to other helpful forum members. Especially HansV!

User avatar
HansV
Administrator
Posts: 78591
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Buttons, as links.

Post by HansV »

One possible explanation is that the control is not named Document Link.
Another is that Document Link is not a text box.
Or that it resides on a subform...
Best wishes,
Hans

User avatar
Steve_in_Kent
4StarLounger
Posts: 421
Joined: 04 Feb 2010, 11:46

Re: Buttons, as links.

Post by Steve_in_Kent »

oops.. yep.. its subform called

Doc_Library_subform
----------------------------------------------------------------------------------------
Owing at LEAST 34 beers to other helpful forum members. Especially HansV!

User avatar
HansV
Administrator
Posts: 78591
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Buttons, as links.

Post by HansV »

Then you should use

Me.BigButton.Caption = Me.Doc_Library_subform![Document Link]
Best wishes,
Hans

User avatar
Steve_in_Kent
4StarLounger
Posts: 421
Joined: 04 Feb 2010, 11:46

Re: Buttons, as links.

Post by Steve_in_Kent »

I think i must have the Event wrong.
because if i try
Me.BigButton.Caption = "Test"

if fails with not finding the button.

I currently have it triggering on the 'On Current' event of the form.
----------------------------------------------------------------------------------------
Owing at LEAST 34 beers to other helpful forum members. Especially HansV!

User avatar
HansV
Administrator
Posts: 78591
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Buttons, as links.

Post by HansV »

Is BigButton on the subform too?
Best wishes,
Hans

User avatar
Steve_in_Kent
4StarLounger
Posts: 421
Joined: 04 Feb 2010, 11:46

Re: Buttons, as links.

Post by Steve_in_Kent »

Ahh. i need to fire on the current, of the subform...
----------------------------------------------------------------------------------------
Owing at LEAST 34 beers to other helpful forum members. Especially HansV!

User avatar
Steve_in_Kent
4StarLounger
Posts: 421
Joined: 04 Feb 2010, 11:46

Re: Buttons, as links.

Post by Steve_in_Kent »

Yes..

It now works, in the sense that it displays a caption.. however.. its displaying the SAME caption, for every button,
rather than the individual records link text.

arggggg
----------------------------------------------------------------------------------------
Owing at LEAST 34 beers to other helpful forum members. Especially HansV!

User avatar
HansV
Administrator
Posts: 78591
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Buttons, as links.

Post by HansV »

In a continuous form, a command button will have the same caption in ALL displayed records, it is not dynamic.
Perhaps it'd be better to use a text box to display the Document Link, and a fixed caption for the buttons.
Best wishes,
Hans

User avatar
Steve_in_Kent
4StarLounger
Posts: 421
Joined: 04 Feb 2010, 11:46

Re: Buttons, as links.

Post by Steve_in_Kent »

I need to trap the on click event of the button.. so that i know when someone has looked at a document. (the button correctly opens the correct document).

Is there anyway to get the .Caption to do Dlookup from the table, to find the name perhaps ?
----------------------------------------------------------------------------------------
Owing at LEAST 34 beers to other helpful forum members. Especially HansV!

User avatar
Steve_in_Kent
4StarLounger
Posts: 421
Joined: 04 Feb 2010, 11:46

Re: Buttons, as links.

Post by Steve_in_Kent »

Or.. how about putting a transparent button over the text field.. would that work ?
----------------------------------------------------------------------------------------
Owing at LEAST 34 beers to other helpful forum members. Especially HansV!

User avatar
HansV
Administrator
Posts: 78591
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Buttons, as links.

Post by HansV »

Yes, that should work.
Best wishes,
Hans

User avatar
Steve_in_Kent
4StarLounger
Posts: 421
Joined: 04 Feb 2010, 11:46

Re: Buttons, as links.

Post by Steve_in_Kent »

Well.. twilight zone weird.

i added the transparent button over, 3 text boxes.

bizzarely, sometimes it will display a clickable link (an arrow as cursor), and other times, an I (with the top and bottom lines)

What stranger, is that it changes in the same bar.. ie: the left side of the button is clickable, but not the right.. so
it must be some setting of the text box underneath it?
----------------------------------------------------------------------------------------
Owing at LEAST 34 beers to other helpful forum members. Especially HansV!

User avatar
HansV
Administrator
Posts: 78591
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Buttons, as links.

Post by HansV »

If the text box already has the focus, the mouse pointer will be the I-beam even though the command button is on top of the text box, and clicking will result in a click in the text box, not on the command button.
The solution is to set the Locked property of the text boxes to Yes and the Enabled property to No. That way, they cannot receive the focus.
Best wishes,
Hans

User avatar
Steve_in_Kent
4StarLounger
Posts: 421
Joined: 04 Feb 2010, 11:46

Re: Buttons, as links.

Post by Steve_in_Kent »

Yep.. looks like that was it exactly hans.

many thanks.
----------------------------------------------------------------------------------------
Owing at LEAST 34 beers to other helpful forum members. Especially HansV!