Solved

VB.net need to open Access DB, then Open Form

Posted on 2004-08-24
4
304 Views
Last Modified: 2012-08-14
Ok, I would like a simple way to create a Windows Application in VB.net, which, when opened, will:

1.Open an Access DB
2. When a button is clicked, open a form.

I have tried the following to open the form:

----------------------------
    Dim oAccess As Application
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        oAccess.DoCmd.OpenForm(FormName:="Visit", _
   View:=Access.AcFormView.acNormal)
------------------------------------------

But this gives me an error saying "‘DoCmd’ is not a member of ‘System.Windows.Forms.Application’"

I also added the reference from the COM tab, Microsoft Access 10.0 Object Library.


Please help!
Thanks.
0
Comment
Question by:DragonReborn214
4 Comments
 
LVL 14

Expert Comment

by:ptakja
ID: 11886578
To open a form you do something like this:

Dim Myfrm As New Form1  ' Form1 or whatever you called your form
Myfrm.Show()   'Will display the form.
0
 
LVL 8

Expert Comment

by:bramsquad
ID: 11886595
DoCmd is no longer supported in vb.net

if you want to open an executable program, youll have to do something like this

Shell("C:/your_path/your_database.mdb")

to open a form, (im assuming a vb.net form, not an access form) you need to

Dim frm As New Form1
Form1.ShowDialog

if you mean you want to open an Access form, youll have to open the form with an Access command, dont remember how to do it, but on the load of the database, you can have a form load.....which will have nothing to do with any vb.net code.  

in fact i dont think you can open an access form with vb.net code...

~b
0
 

Author Comment

by:DragonReborn214
ID: 11886627
I am trying to open an access form.

This article kind of goes into detail, but I am not able to do the doCmd

http://support.microsoft.com/default.aspx?scid=kb%3BEN-US%3B317113

0
 
LVL 2

Accepted Solution

by:
Mehrdad_Y earned 50 total points
ID: 11895792
You have to use office automation.
To do this, make a reference to Microsoft Access 10 or 11 Object Library
Define a variable of type: Microsoft.Office.Interop.Access.Application
Construct it. (Use the "New" keyword)
Make it to open your MDB file.
Now you can use the docmd
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

803 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