I have a access searchable form that displays results in a subform.
One of the fields in the subform results is ImagePath.
I want to be able to select a record from the results, then click a button that would open a pdf for that specific record using ImagePath.
14 2223
You could use a button on the record with code like the following: - Private Sub btn_Open_Click
-
Application.FollowHyperLink Me.ImagePath
-
End Sub
NeoPa 32,556
Expert Mod 16PB
The fact that this is a subform doesn't change anything. The same approach could be used on any form.
You could also trigger the code on either the change of record, or double-clicking on the control with the image path in it. Both of these would save the extra space for the button, which is especially a problem if the form is in Continuous Form mode.
Curios how would you accomplish this:
You could also trigger the code on either the change of record
I imagine using the subforms current event, but that would fire in alot of unwanted cases, which you would have to code for.
If the imagepath is a visible control, another option (as per NeoPa's suggestion) could be to change the controls properties to format it as a hyperlink, and then code the opening to occur on DoubleClick for example.
Thanks for your replies guys.
TheSmileyCoder I tried what you suggested and I get a - Compile error: Method or data member not found.
So I tried changing Me.ImagePath to Me!ImagePath and then got the below error. - Run-time error '2465' Microsoft Office Access Can't find field 'ImagePath' referred to in your expression.
Any idea?
In your first post you stated that the field in the supreport was called ImagePath.
If access can't find ImagePath its likely because you made a mistake in telling us the name of the field/control containing the path to your file.
NeoPa 32,556
Expert Mod 16PB Smiley:
If access can't find ImagePath its likely because you made a mistake in telling us the name of the field/control containing the path to your file.
Almost certainly. I can think of no alternative explanation.
I am completely new and I have no idea what I must be missing to get this to work.
I don't know if you have time to look at my test db for me.
If not, I'll still play around to get it to work.
Thanks
NeoPa 32,556
Expert Mod 16PB Ablevins:
I am completely new and I have no idea what I must be missing to get this to work.
Have you considered the idea already put forward, that the control name is incorrect?
Going through someone's project is something which takes a lot more effort than dealing with intelligent textual responses in the thread. I won't say none of us ever does it, but I certainly wouldn't consider it while the thread still has outstanding ideas proposed that have apparently not been considered yet. If we get to that stage then we will generally inform you and give some instructions on how you would go about preparing for that properly.
You placed the button in the main unbound form. Whichever "item" click you choose to active the record, it will be easiest if it is on the subform itself. As the item is clicked a number of things happen. The subform receives focus, then the record under the mouse receives focus, then the button receives focus, and then the click event is fired. As you can see part of this process is that the record is selected. How else shall access know which records imagepath it is you want to open?
So make sure to use a click event that is on the subforms DETAIL area. It could be the click of any of the textboxes, OR a button. Then within that click event use the before mentioned Application.Followhyperlink
Ohhhh, I didn't even think about that. I will give it a try again.
Thanks
TheSmileyCoder,
I did what you suggested and it kind of works.
When I click the button, it opens the pdf then quickly closes it. And this all happens fast enough that I can't even see what the pdf is.
Any ideas why this would happen?
Sorry, no idea at all. I presume if you open the same pdf manually there is nothing wrong?
zmbd 5,501
Expert Mod 4TB
Please read the following: Before Posting (VBA or SQL) Code
Please double check that you have done the first part of the article linked to.
Make sure that you can compile your code without any errors. One thing to note, the compiler stops at the FIRST error encountered. You must REPEAT the compile step.
Once you've done this, please post the code behind your click event for opening the PDF.
NeoPa 32,556
Expert Mod 16PB Ablevins:
When I click the button, it opens the pdf then quickly closes it.
This sort of behaviour is normally seen when something happens related to an object variable that is stored locally, then goes out of scope and gets cleared down. I can't think what might fit that pattern when dealing with a hyperlink, but we'd need to see the code to be sure. Please follow Z's instructions carefully before posting the full code from the procedure in question.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: SPEAKIT |
last post by:
I'm sorry to ask what must be a very simple question, but I just can't seem
to get this to work.
Right now I am using the javascript 'prompt' to enter a photoid and the
script that I am using uses...
|
by: Verner Vaz |
last post by:
Select Email ID based on 'a' selected radio button
Hello there,
I have a simple form with some fields to be filled in and when submitted
is emailed to a couple of email ID.
Now, this form...
|
by: Nicolae Fieraru |
last post by:
Hi All,
I have a table with records and I want to add an image to every record.
One of the fields is an OLE Object and another is a text which contains the
image name. I want to insert an image...
|
by: dscarbor |
last post by:
I have a simple form with 4 fields, and a subform that retrieves records that are potential matches based on a query.
The user will use the ID from the subform record and enter it into one of the...
|
by: darnnnel |
last post by:
I have a form and a subform. The subform is displayed as a datasheet. When a user selects a record on the list, I would like the parent for to show the contents of the record selected. Access 2007,...
|
by: WyvsEyeView |
last post by:
Okay, now I need to open a form (frmTopics) and select the same record that has been double-clicked on in a separate form (frmTopicsFound). Here are the details:
frmTopicsFound contains datasheet...
|
by: angelicdevil |
last post by:
i have listbox 1 which displays status , based on selection of status listbox 2 displays usernames. and based on username selected the textbox displays the email id.
its working fine till...
|
by: svjim |
last post by:
I am working on an iPhone application which uses a version of safari (UIWebView) to display web pages. I want to be able to capture images shown on the webview. To do so, I can capture a "touch...
|
by: londres9b |
last post by:
Let's say I have a page called page.php. And let's also say I have an images folder.
How can I make the php page display the images on the folder?
But that's not the whole thing... What I really...
|
by: dekk |
last post by:
Overview
- Subform called 'Time'
- Subform fields are named:
Well Ref - this is the well reference
Start Time - self explanatory
End Time - self explanatory
Activity - combo box selection...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |