On Click button Code

Squid1622

Registered User.
Local time
Today, 01:04
Joined
May 14, 2012
Messages
49
So here's my issue... I have a database of properties. Each of these properties has several pdf documents that are associated with each property. In one table I have all the properties and information. In the second table I have all the hyperlinks to the documents.

What I would like to do is have a button on the form that would open the hyperlink for the current record. I've been having issues with this and I get an error message that says either "Procedure declaration does not match description of event or procedure having the same name," or "Object doesn't support this property or method." The defining difference between the error message is whether I place the code under a private sub or a function. What am I missing?

Here's what I have:

Code:
Private Sub propSurvey_Click()
Application.FollowHyperlink [Me.propSurvey]
End Sub

I know the code is simple (and probably not complete), but it's just hanging me up.
 
Try this, as you wouldn't want the brackets:

Application.FollowHyperlink Me.propSurvey

That assumes propSurvey contains a path to a file.
 
pbaldy,

I tried your suggestion and I'm still getting ,"Object doesn't support this property or method" message.
 
What kind of control is that? This is from a db I happen to be working on, where the control is a textbox:

Code:
Private Sub txtAttachment_DblClick(Cancel As Integer)
  Application.FollowHyperlink Me.txtAttachment
End Sub
 
I saw that coding on another post but I couldn't make it work. My understanding of this may be flawed. I'm not trying to pull from a textbox on a form. The path of the file is located in a table with text formatting. I'm trying to use a button to pull linked document directly from the table via the hyperlink.
 
So propSurvey is a button? You can't refer to it for the path then, since it has no Value property. You'd have to hard-code the path or something. One way or the other you have to tell Access the path to the file you want opened. In my code it's in the textbox.
 
I should make it less confusing. propSurvey is the button, but the field the hyperlink is in is also labled propSurvey. I will rename the button to be SurveyDoc. Is this relevant to how the question appears?

Now the code would appear:

Code:
Private SurveyDoc_Click()
Application.FollowHyperlink Me.propSurvey
End Sub
 
Definitely a good idea to change the name. Does it work now? If not, what exactly does propSurvey contain? Is it on the form? It should not have let you have 2 controls with the same name, which makes me wonder if that field is available on the form.
 
propSurvey contains the file path to where the particular document is located. It does not appear anywhere on the form, it only exists in the record on the table. I can place that field on the form as a simple bound textbox control
 
That would be simplest. The alternative is to look it up with a recordset or DLookup().
 
I did some looking around on the DLookup() and the Recordset. I think the DLookup might be the best solution. Because this DB is going to be viewed by multiple people, I don't want them to be able to see the file path for the documents. What would the syntax/coding be for a DLookup() be if once the record was found it would then follow the hyperlink?
 

Users who are viewing this thread

Back
Top Bottom