Open Excel File from Access Button

  • Thread starter http://www.visual-basic-data-mining.net/forum
  • Start date
H

http://www.visual-basic-data-mining.net/forum

Okay, I have an Access program. I want to create a button on a record form that opens a specific Excel file based on a field name of the record. Example: I have a field labeled "Change #". The field is the format of YYYY-### (2004-006) for tracking the changes. I want to create a button where the user can click and excel will open the corresponding detailed excel file that the requester submitted. The file names are saved the same as the field; 2004-006.xls. So I want the code to refer to the field of the current record and open that .xls file.

This is far above my basic VB coding, any suggestions?



Thanks
 
X

xpnovice

If anyone has the answer to this, in simple VB terms I would also be
interested, as I have same problem (different scenario) posted on
access.macros but as yet I have not seen a solution.

Thanks
John
in message Okay, I have an Access program. I want to create a button on a record form
that opens a specific Excel file based on a field name of the record.
Example: I have a field labeled "Change #". The field is the format of
YYYY-### (2004-006) for tracking the changes. I want to create a button
where the user can click and excel will open the corresponding detailed
excel file that the requester submitted. The file names are saved the same
as the field; 2004-006.xls. So I want the code to refer to the field of the
current record and open that .xls file.
This is far above my basic VB coding, any suggestions?

Thanks
 
A

Arvin Meyer

Try the ShellExecute function:

http://www.mvps.org/access/api/api0018.htm

Using that, the single line of code would be:

fHandleFile("C:\FolderName" & Me.txtFileName & ".xls", Win_NORMAL)

where txtFileName was the name of the textbox holding the file name.
Depending upon whether or not the .xls was part of your saved data, you may
need to concatenate it onto the end, as above.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access

in message Okay, I have an Access program. I want to create a button on a record form
that opens a specific Excel file based on a field name of the record.
Example: I have a field labeled "Change #". The field is the format of
YYYY-### (2004-006) for tracking the changes. I want to create a button
where the user can click and excel will open the corresponding detailed
excel file that the requester submitted. The file names are saved the same
as the field; 2004-006.xls. So I want the code to refer to the field of the
current record and open that .xls file.

This is far above my basic VB coding, any suggestions?



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