Solved

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

Posted on 2004-08-24
4
275 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now