How to start MS Access using VB.Net

Starting MS Access application using VB.Net and controlling its forms

Page 1 of 1

1 Replies - 11112 Views - Last Post: 08 December 2008 - 03:15 PM Rate Topic: -----

#1 jantikey  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 08-December 08

How to start MS Access using VB.Net

Posted 08 December 2008 - 03:55 AM

Hello Dear,
I need help how to start MS Access using VB.Net. I am programming in AUTOCAD. I want the user to select a Node with specific Node number. This Node Number will be used as a value for the variable which will then be referenced in a query in extracting List of Documents associated with the Node Number. I would like to start MS Access without using OleDB connection, spark it up and open it's forms based on the query.
Please help.

Thanks a lot.
JAN

Is This A Good Question/Topic? 0
  • +

Replies To: How to start MS Access using VB.Net

#2 DataFlowJoe  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 06-December 08

Re: How to start MS Access using VB.Net

Posted 08 December 2008 - 03:15 PM

I've copied this help topic directly from Access 2003, it explains how you can do this. HTH

==============================================

Command Function
You can use the Command function to return the argument portion of the command line used to launch Microsoft Access.

Remarks
When Microsoft Access is launched from the command line, any portion of the command line that follows the /cmd option is passed to the program as the command-line argument. You can use the Command function to return the argument that has been passed.

To change a command-line argument once a database has been opened, click Options on the Tools menu. On the Advanced tab of the Options dialog box, enter a new argument in the Command Line Arguments box. The Command function will now return the new argument you have entered.

When the Command function is used anywhere other than in Visual Basic code in a module, you must include empty parentheses after the function. For example, to use the Command function in a text box on a form, you would set the ControlSource property of the text box to an expression like the following:

=Command()

Example
The following example shows how to launch Microsoft Access with a command-line argument, and then shows how to return the value of this argument by using the Command function.

To test this example, click the Windows Start button and click Run. Type the following code in the Run dialog box on a single line. (You must surround the parts of the command line information in quotation marks).

"C:\Program Files\Microsoft Office\Office10\Msaccess.exe" _
"C:\Program Files\Microsoft Office\Office10\Samples\Northwind.mdb" /cmd "Orders"

Next, create a new module in the Northwind sample database and add the following Sub procedure:

Public Sub CheckCommandLine()

' Check the value returned by Command function and display
' the appropriate form.
If Command = "Orders" Then
DoCmd.OpenForm "Orders"
ElseIf Command = "Employees" Then
DoCmd.OpenForm "Employees"
Else
Exit Sub
End If

End Sub

When you call this procedure, Microsoft Access will open the Orders form. You can create an AutoExec macro to call this procedure automatically when the database is opened.


==========================================
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1