Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

25 Experts available now in Live!

Get 1:1 Help Now