Have Access pass a field name to an external app

G

Guest

Hello! I'm looking for guidance in doing the following:

I want to be able to click on an object (button or image) and have Access read the value of a field in the current record and pass it to the run app dialog box. An example:

"Workstation" value for current record is COMPUTER24
When object clicked, have Access run this command line: notepad \\server\share\computer24.txt

Is there a way to get Access to do this? Can anyone point me toward a help page in the knowledge base?

Thanks in advance!

Chris Brown
Converse Co School Dist #1
Douglas, WY US
 
G

Gary Miller

From Access 97 Help...

The FollowHyperlink method opens the document or Web page
specified by a hyperlink address.

Syntax

[application.]FollowHyperlink address, [subaddress],
[newwindow], [addhistory], [extrainfo], [method],
[headerinfo]

The FollowHyperlink method has the following arguments.

Argument Description
application The Microsoft Access Application object.
address A string expression that evaluates to a valid
hyperlink address.
subaddress A string expression that evaluates to a named
location in the document specified by the address argument.
The default is a zero-length string (" ").
newwindow A Boolean value where True (-1) opens the document
in a new window and False (0) opens the document in the
current window. The default is False.
addhistory A Boolean value where True adds the hyperlink to
the History folder and False doesn't add the hyperlink to
the History folder. The default is True.
extrainfo A string or an array of Byte data that specifies
additional information for navigating to a hyperlink. For
example, this argument may be used to specify a search
parameter for an .asp or .idc file. In your Web browser, the
extrainfo argument may appear after the hyperlink address,
separated from the address by a question mark (?). You don't
need to include the question mark when you specify the
extrainfo argument.
method An Integer value that specifies how the extrainfo
argument is attached. The method argument may be one of the
following intrinsic constants.
Constant Description

msoMethodGet The extrainfo argument is appended to the
hyperlink address and can only be a string. This value is
passed by default.
msoMethodPost The extrainfo argument is posted, either as a
string or as an array of type Byte.
headerinfo A string that specifies header information. By
default the headerinfo argument is a zero-length string.
Remarks

By using the FollowHyperlink method, you can follow a
hyperlink that doesn't exist in a control. This hyperlink
may be supplied by you or by the user. For example, you can
prompt a user to enter a hyperlink address in a dialog box,
then use the FollowHyperlink method to follow that
hyperlink.
You can use the extrainfo and method arguments to supply
additional information when navigating to a hyperlink. For
example, you can supply parameters to a search engine. To
search the Yahoo site for information on Microsoft, you
might call the FollowHyperlink method as follows:

Application.FollowHyperlink
"http://search.yahoo.com/bin/search", _
, , , "p=Microsoft", msoMethodGet

You can use the Follow method to follow a hyperlink
associated with a control.

--

Gary Miller
Gary Miller Computer Services
Sisters, OR
________________________
message
Hello! I'm looking for guidance in doing the following:

I want to be able to click on an object (button or image)
and have Access read the value of a field in the current
record and pass it to the run app dialog box. An example:
"Workstation" value for current record is COMPUTER24
When object clicked, have Access run this command line:
notepad \\server\share\computer24.txt
Is there a way to get Access to do this? Can anyone point
me toward a help page in the knowledge base?
 
B

Bogdan Zamfir

Hi,

You can use API function shellexecute, which will open the file in the
application that is its default association (the same way as you can open
any file by double-click it directly in explorer)

Enter this at the begining of a module:

Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation _
As String, ByVal lpFile As String, ByVal lpParameters _
As String, ByVal lpDirectory As String, ByVal nShowCmd _
As Long) As Long

Global Const SW_SHOWNORMAL = 1


Then, in your code, write something as below:

.....
' suppose you retrieved the data with the filename you want to open in
recordset rs

nRetVal = ShellExecute(0, "open", "\\server\share\path\" & rs!workstation &
".txt" , "", "\\server\share\path\", SW_SHOWNORMAL)

Beside this, you can open any other file type, and as long there is an
association in windows registry between the file type (extension) and an
installed application, shellexecute will know to open the file in the
appropriate app.

HTH,
Bogdan Zamfir
_________________________

Independent consultant


Chris Brown said:
Hello! I'm looking for guidance in doing the following:

I want to be able to click on an object (button or image) and have Access
read the value of a field in the current record and pass it to the run app
dialog box. An example:
"Workstation" value for current record is COMPUTER24
When object clicked, have Access run this command line: notepad \\server\share\computer24.txt

Is there a way to get Access to do this? Can anyone point me toward a
help page in the knowledge base?
 
G

Guest

Thanks, Bogdan and Gary! I will try both of these tonight. This is for a tech database we use in my district -- I wanted to be able to press a button on a form and have a hardware report (stored on a network share) open up, based on the name of hte computer I'm viewing. Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top