Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Open MS Access from Visual Basic Form

Posted on 2006-05-26
5
Medium Priority
?
189 Views
Last Modified: 2013-11-25
Can I place a control (button) on a VB form that will launch an Access application? If so, how is that done?
0
Comment
Question by:EMCIT
  • 2
  • 2
5 Comments
 
LVL 66

Accepted Solution

by:
Jim Horn earned 2000 total points
ID: 16770387
Sure.  

In your VB Editor screen you should see a command button icon.  Click on the command button icon, then click-and-hold where you want the upper left of the button, drag to where you want the lower right of the button, then release.  You should see a command button.
Double-click on the command button to get to the VB Code Editor.  

You should see this in code...

Private Sub Command1_Click()

End Sub

... now modify it to look like this...



   
Private Sub Command1_Click()
Dim v

Dim sAccess As String
Dim sYourApp As String

sAccess = "c:\Program Files\Microsoft Office\Office\msaccess.exe"   '<--- Change if you are using a version higher than A2K
sYourApp = "c:\db1.mdb"   '<-- Change to wherever your app is

v = Shell(sAccess & " " & sYourApp, vbMaximizedFocus)

End Sub


Save, then run.

Hope this helps.
-Jim


0
 
LVL 9

Expert Comment

by:pradapkumar
ID: 16770408
Yes you can do it.
On Click event of that command button call the executable file name using shell command.
Normally the access executable file is stored in C:\Program Files\Microsoft Office\Office10\.
you can call that executable using the following command for example

Shell "C:\Program Files\Microsoft Office\Office10\MSACCESS"

the above example calls the msaccess executable(i.e. application) for MS Office XP.

please check the application's executable location according to your version.

@};-
0
 
LVL 9

Expert Comment

by:pradapkumar
ID: 16770414
oops little bit slower response.
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 16772078
I prefer the use of the API call ShellExecute

http://www.vbaccelerator.com/codelib/shell/shellex.htm

Specify full pathname of file and it will open it using the registered program
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 16775466
Thanks for the grade.  Good luck with your project.  -Jim
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question