open excel file

L

lance

Hi,

I'm fairly new to MS Access but have been working on a project for a
friend. I was hoping I might be able to get some help.

I have a form called "Customers" which edits the "Customers" Table. I
have a Primary Key column called "CustomerID" which is set to
Autonumber.

On this form, I want to create a command button which will open a
specific excel file. The excel filename would be the value of the
"CustomerID" field. So if the value of "CustomerID" is 7, then this
command button will try to open "7.xls" in a subdirectory of the
database's directory called \customer files .

I will manually create these excel files and ensure that they are in
the \customer files subdirectory and named appropiately (ie 1.xls,
2.xls, etc).

If somebody could help me out with the code I would really appreciate
it. I've searched google for sample code for opening excel files, but
can't find any examples that use a variable filled from a field.

Thanks
Lance Purcell
(e-mail address removed)
 
A

aclelland

Hi,

I'm fairly new to MS Access but have been working on a project for a
friend. I was hoping I might be able to get some help.

I have a form called "Customers" which edits the "Customers" Table. I
have a Primary Key column called "CustomerID" which is set to
Autonumber.

On this form, I want to create a command button which will open a
specific excel file. The excel filename would be the value of the
"CustomerID" field. So if the value of "CustomerID" is 7, then this
command button will try to open "7.xls" in a subdirectory of the
database's directory called \customer files .

I will manually create these excel files and ensure that they are in
the \customer files subdirectory and named appropiately (ie 1.xls,
2.xls, etc).

If somebody could help me out with the code I would really appreciate
it. I've searched google for sample code for opening excel files, but
can't find any examples that use a variable filled from a field.

Thanks
Lance Purcell
(e-mail address removed)

You can use:
Application.FollowHyperlink myURLVar & "\" & CustomerID & ".xls"

where myURLVar is the location of the folder where the xls files are
located.

Only problem would be if Access is being run in safe mode. The user
will be shown a dialog box with a warning message.

Hope that helps,
Alan
 

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