How to selectively open an Access 2007 db

R

RansomEli

Depending upon user input, I want to open one of 3 possible MS Access
databases. What is the best way to do this? Can I do this inside of MS
Access or would it be better to create a C# program that actually calls the
MS access programs?

Thanks.
 
J

Jack Leach

What interface are you using to get the information from the user? If you're
in VBA, do a comparison of whatever criteria, and set a variable to the
pathname based on that. Then run the Shell function to open the database
from the variable.

Dim sDatabase As String 'filename
If <some criteria> Then
sDatabase = "C:\thisdb.accdb"
Else If <some criteria> Then
sDatabase = "C:\thatdb.accdb"
Else If <other criteria> Then
sDatabase = "C:\otherdb.accdb"
Else
'Anything else
sDatabase = "C:\defaultdb.accdb"
End If

Shell sDatabase


Keep in mind that, from doing this from access, you would then have two
instances of access running...

hth
--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
H

Heinrich Moser

RansomEli said:
Depending upon user input, I want to open one of 3 possible MS Access
databases. What is the best way to do this? Can I do this inside of MS
Access or would it be better to create a C# program that actually calls the
MS access programs?

The easiest solution would be to put three shortcuts on the user's
desktop. Since this is probably not what you want, I suggest that you
provide a bit more detail about the nature of the "user input". ;-)

Greetings,
Heinzi
 
R

RansomEli

You are right, I did not give much preliminary info. Sorry. I have an
application which has 3 distinct, separate Access databases. I would like
the user to open a C# 'shell' program (or a MS Access switchboard), and then
select which database they would like to execute. Each database will have its
own main form.
Ideally, I would like to hide all the details from the user. For all they
know, they are executing a single program which magically lets them update
all sorts of data. I would like to use C# and keep only one instance of
Access running., if possible.

Thanks for the quick responses and information.
 
J

Jack Leach

I have an application which has 3 distinct, separate Access databases.

What is this application? Is it in C, Access, any other programming
language that can collect user input?? How does any application "have" 3
distinct applications of any type? Link to them maybe, but...? You still
haven't given us any indication on how the user enters information, other
than saying 'through an application'...

For all they
know, they are executing a single program which magically lets them update
all sorts of data.

Any reason you can't use one access frontend linked to multiple backends?
Then if your input application happens to be access, you can do everything in
one application, which is generally ideal.

If your application that the users get the input from is not in Access (but
maybe C#?), then you should probably seek a forum based on whatever
application you are gathering the data from, as this would be the application
you will use to make the decision for which access app to open.

And just for the record, this type of if/then functionality with variables
can be written for just about any programming platform. You can open a
selected access app from a batch file if you desire. Coming to an Access VBA
forum to ask how to open one of three files without saying if you are using
Access as the interface to do so isn't exactly the best way to get answers...
please make some more sense in your question.


--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
A

Albert D. Kallal

Loading the CLR runtime system to run a few lines of C# is likely not the
best approach from a memory point of view....


I would simply buld an access application with a form with a few
buttions....

The code behind the button to launch word, pdf, excel, or another access
application would be:


application.Followhyperlink "path name to windows file"
 
H

Heinrich Moser

RansomEli said:
You are right, I did not give much preliminary info. Sorry. I have an
application which has 3 distinct, separate Access databases. I would like
the user to open a C# 'shell' program (or a MS Access switchboard), and then
select which database they would like to execute. Each database will have its
own main form.
Ideally, I would like to hide all the details from the user. For all they
know, they are executing a single program which magically lets them update
all sorts of data. I would like to use C# and keep only one instance of
Access running., if possible.

I think I understand your problem now. Indeed, I agree that a small C#
program is probably the most elegant solution. I don't think that you
can programmatically "switch" from one (frontend) mdb to another one
within the same Access instance, so an "Access-only" solution would
probably require you to start a second Access instance after the user
made his selection.

Greetings,
Heinzi
 

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