Comman button on a continuous form opening a link from the record

SShafeeq

Registered User.
Local time
Today, 08:57
Joined
Jan 4, 2011
Messages
32
Command button on a continuous form opening a link from the record

Hey

I have a continuous form called “EFSearchForm” which has bounded fields from “ElectronicFileDatabase”. This form has fields titled “OriginalName”, “FileName”, “DataType” and “Attachment”.

The attachment field has a hyperlink to relevant files on the C: drive. Now basically, I want to firstly hide the attachment field and secondly I want there to be a button called “View” on each record which should open the link given in the attachment field for each of the record. Meaning when I look at the list of records given on the continuous form I want a button at the end of the record that the user can click that says “view”, and it opens the record being referred to.


I am fairly a beginner in Acces and am using the 2007 version. Can anyone please tell me how to code the button to allow me to do this?
Thanks in advance!
 
Last edited:
Adding a CommandButton to your form will make it appear on each entry of the Continuous View. Pressing the button will make *that* record the Current record so you can reference any of the other controls on the form and the Values in them will be from the Current record. Will you need to Shell Out to open the "attachment"? If so then maybe this link will be useful: http://www.mvps.org/access/api/api0004.htm
 
Ok, i got your first part, however I do not know what you mean by Shell Out?

The attachments are various file types from images to pdfs to docs to xls.

Does anyone know what coding I should do behind the button to make it work?
 
Ok, thats great. However can anyone give me a shell out code i require with description? I want to understand how exactly to do this so I can trouble shoot latter if need be.
 
When you "Shell Out" it is the same as if you typed it on the command line. Windows looks up the file association and uses hopefully the right program to execute the document. The link I gave you has a sample line of code if I remember correctly.
 
No offense guys but I am getting a bit frustrated here. Yes now I know what a shell out is, but can anyone tell me how I can implement it to my context IN SPECIFIC? RuralGuy, I have followed your link, and I do not understand exactly how to put that code onto my button.

Also I have been trying to code my button using DLookup and Application.FollowHyperlink, yet when I click on the button, NOTHING HAPPENS, and its driving me crazy! What am I doing wrong?
 
You could use something like the following;
Code:
    Dim stFileName As String
    
    stFileName = Me.YourFileNameLocation & ".xls"
    
    Dim xlApp As Excel.Application
    Set xlApp = CreateObject("Excel.Application")

    xlApp.Visible = True

    xlApp.Workbooks.Open stFileName, True, False

    Set xlApp = Nothing

Note; You will need to associate the Microsoft Excel 11.0 Object Library using the Tools menu Reference sub menu
 
Thanks JBB, but maybe im not being specific enough.

I have a Form that looks very similar to this:

|OriginalName________|FileName_____________|DataType___|Attachments
|Legislations&Bills_____|0000.Legislation_GOP__ |PDF________|[VIEW]
|Registration Laws____|0013.Reg Laws_POI____|DOC________|[VIEW]

My database looks similar to above only rather then attachments it has a field called "Links" that has hyperlinks in the format such as D:/Country Information/Laws/0000.Legislation_GOP.pdf.

Now the form is a continuous form. I want the button [VIEW] to be able to look at the corresponding hyperlink in the Link field and open the document.

How do I code my button so it can do this?
 
If you don't need to Shell and Wait just use Shell. An example:
Code:
 Shell "Explorer.exe " & Me![[COLOR=Red]FullPathToFile[/COLOR]]
Notice you need the full path to the file located on the C Drive. The file name alone is not sufficient. Explorer.exe helps to associate the file with its launch program. Also note the space after Explorer.exe

The ShellWait() function follows the same format as above.
 
Note; You will need to associate the Microsoft Excel 11.0 Object Library using the Tools menu Reference sub menu
If you use late binding then you don't need the reference to Excel, like so:
Code:
Dim xlApp As [B][COLOR=Red]Object[/COLOR][/B]
Set xlApp = CreateObject("Excel.Application")
This is just fyi.
 
Thank you for your reply. Ok, so i tried this. My fullpathname is saved in the 'Links' field in the ElectronicFileDatabase.

I coded my button (which is Command82) as follows:

Private Sub Command82_Click()

Shell "Explorer.exe " & Me![(Dlookup("[Links]", "ElectronicFileDatabase"))]

End Sub

I click on my button and it does nothing! As in no syntax error or anything! It just does nothing! What am I doing wrong!!
 
Add the [Links] field to the record source of your form, drop the field onto the form as a textbox, make the textbox invisible and use this:

Shell "Explorer.exe " & Me![Links]

No need for the DLookup().
 

Users who are viewing this thread

Back
Top Bottom