By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,121 Members | 1,782 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,121 IT Pros & Developers. It's quick & easy.

open a Microsoft Access form

P: n/a
Hi,

How do I open a Microsoft Access 2003 form from Visual Basic.net

Thanks in advance
bbdobuddy

Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
bb

These kind of questions are mostly answered by Paul Clement.

Until he is awake/(active in this newsgroup) a message from him about your
question.

http://groups-beta.google.com/group/...eb9b56a39c4392

I hope this helps so far.

Cor
Nov 21 '05 #2

P: n/a
On Tue, 8 Feb 2005 15:47:03 -0800, bbdobuddy <bb*******@discussions.microsoft.com> wrote:

Hi,

How do I open a Microsoft Access 2003 form from Visual Basic.net


I used the Office PIA
(http://msdn.microsoft.com/library/de...HV01083002.asp)
for this but you can also use the interop assembly generated when you add the Access COM reference
to your project:
Public Sub AutomateAccess()

Dim AccessApplication As New Microsoft.Office.Interop.Access.Application

If Not AccessApplication.Visible = True Then
AccessApplication.Visible = True
End If

AccessApplication.OpenCurrentDatabase("e:\My Documents\db1.mdb")
AccessApplication.DoCmd.OpenForm("MyAccessFormName ",
Microsoft.Office.Interop.Access.AcFormView.acNorma l)

'...
'...

AccessApplication.Quit()

End Sub
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 21 '05 #3

P: n/a
I'm trying to use similar code as you used below, however, as mentioned in
the link you provided, the PIAs are not to be used in the application setup
process. If I don't include them in the setup then this code wont run on
the client. If I do include them in the setup, the code will run on the
client, but 1) the msdn documentation says we don't have the right to
distribute these, and 2) by installing these on the client we could corrupt
the office registration on the client when they do an un-install of our
applications. I was confused by the documentation in the URL as it didn't
clarify how to distribute the .net app and have the client be able to use
the code you listed below.

Do you have any advise on how to go about this?

Here's me code which is similar to your code:
Public Function OpenApp() As FileMngr
Try
Dim sFile As String = "some path to ms access"

Dim sCrit As New StringBuilder
Dim dr As wsMain.dsUser.tbCtlRow
sCrit = "some stuff for access to use"
'Startup Access Now
Dim AccessApplication As New Access.Application
'Make it visible ?should we do this later?
If Not AccessApplication.Visible = True Then
AccessApplication.Visible = True
End If
'Open app
AccessApplication.OpenCurrentDatabase(sFile)
'Call a function to start things running and pass in the user rights
that will be used to initalize everything
AccessApplication.Run("Main", sCrit.ToString)
Return FileMngr.Success

Catch ex As Exception
ErrLog(ex)
End Try
End Function
The msdn documentaion said to set the property (Copy Local) on the reference
to access to "False". When I did that, I get the following error:

System.IO.FileNotFoundException: File or assembly name Interop.Access, or
one of its dependencies, was not found.
File name: "Interop.Access"
at TransAct.ClientAppHelper.OpenApp()
at TransAct.frmMain.OpenClientApp() in
D:\nwis\Apps\LandMan\VS\TransAct\TransAct\frmMain. vb:line 553

=== Pre-bind state information ===
LOG: DisplayName = Interop.Access, Version=9.0.0.0, Culture=neutral,
PublicKeyToken=null
(Fully-specified)
LOG: Appbase = D:\nwis\Apps\LandMan\VS\TransAct\TransAct\bin\
LOG: Initial PrivatePath = NULL
Calling assembly : TransAct, Version=1.0.1887.28847, Culture=neutral,
PublicKeyToken=null.
===

LOG: Policy not being applied to reference at this time (private, custom,
partial, or location-based assembly bind).
LOG: Post-policy reference: Interop.Access, Version=9.0.0.0,
Culture=neutral, PublicKeyToken=null
LOG: Attempting download of new URL
file:///D:/nwis/Apps/LandMan/VS/TransAct/TransAct/bin/Interop.Access.DLL.
LOG: Attempting download of new URL
file:///D:/nwis/Apps/LandMan/VS/TransAct/TransAct/bin/Interop.Access/Interop.Access.DLL.
LOG: Attempting download of new URL
file:///D:/nwis/Apps/LandMan/VS/TransAct/TransAct/bin/Interop.Access.EXE.
LOG: Attempting download of new URL
file:///D:/nwis/Apps/LandMan/VS/TransAct/TransAct/bin/Interop.Access/Interop.Access.EXE.
</Exception>
</Errors>
<Errors d2p1:id="2" d2p1:TimeStamp="2005-03-02T16:10:40.6916071-06:00"
xmlns:d2p1="http://tempuri.org/dsErrorHandler.xsd">
<Exception>System.IO.FileNotFoundException: File or assembly name
Interop.Access, or one of its dependencies, was not found.
File name: "Interop.Access"
at TransAct.ClientAppHelper.OpenApp()
at TransAct.frmMain.OpenClientApp() in
D:\nwis\Apps\LandMan\VS\TransAct\TransAct\frmMain. vb:line 553

=== Pre-bind state information ===
LOG: DisplayName = Interop.Access, Version=9.0.0.0, Culture=neutral,
PublicKeyToken=null
(Fully-specified)
LOG: Appbase = D:\nwis\Apps\LandMan\VS\TransAct\TransAct\bin\
LOG: Initial PrivatePath = NULL
Calling assembly : TransAct, Version=1.0.1887.28847, Culture=neutral,
PublicKeyToken=null.
===

LOG: Policy not being applied to reference at this time (private, custom,
partial, or location-based assembly bind).
LOG: Post-policy reference: Interop.Access, Version=9.0.0.0,
Culture=neutral, PublicKeyToken=null
LOG: Attempting download of new URL
file:///D:/nwis/Apps/LandMan/VS/TransAct/TransAct/bin/Interop.Access.DLL.
LOG: Attempting download of new URL
file:///D:/nwis/Apps/LandMan/VS/TransAct/TransAct/bin/Interop.Access/Interop.Access.DLL.
LOG: Attempting download of new URL
file:///D:/nwis/Apps/LandMan/VS/TransAct/TransAct/bin/Interop.Access.EXE.
LOG: Attempting download of new URL
file:///D:/nwis/Apps/LandMan/VS/TransAct/TransAct/bin/Interop.Access/Interop.Access.EXE.

Thanks for any help anyone can offer.

--
mo*******@nospam.com
"Paul Clement" <Us***********************@swspectrum.com> wrote in message
news:05********************************@4ax.com...
On Tue, 8 Feb 2005 15:47:03 -0800, bbdobuddy
<bb*******@discussions.microsoft.com> wrote:

Hi,

How do I open a Microsoft Access 2003 form from Visual Basic.net


I used the Office PIA
(http://msdn.microsoft.com/library/de...HV01083002.asp)
for this but you can also use the interop assembly generated when you add
the Access COM reference
to your project:
Public Sub AutomateAccess()

Dim AccessApplication As New
Microsoft.Office.Interop.Access.Application

If Not AccessApplication.Visible = True Then
AccessApplication.Visible = True
End If

AccessApplication.OpenCurrentDatabase("e:\My Documents\db1.mdb")
AccessApplication.DoCmd.OpenForm("MyAccessFormName ",
Microsoft.Office.Interop.Access.AcFormView.acNorma l)

'...
'...

AccessApplication.Quit()

End Sub
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)

Nov 21 '05 #4

P: n/a
On Wed, 2 Mar 2005 16:30:03 -0600, "moondaddy" <mo*******@nospam.com> wrote:

I'm trying to use similar code as you used below, however, as mentioned in
the link you provided, the PIAs are not to be used in the application setup
process. If I don't include them in the setup then this code wont run on
the client. If I do include them in the setup, the code will run on the
client, but 1) the msdn documentation says we don't have the right to
distribute these, and 2) by installing these on the client we could corrupt
the office registration on the client when they do an un-install of our
applications. I was confused by the documentation in the URL as it didn't
clarify how to distribute the .net app and have the client be able to use
the code you listed below.

Do you have any advise on how to go about this?

Here's me code which is similar to your code:


Public Function OpenApp() As FileMngr
Try
Dim sFile As String = "some path to ms access"

Dim sCrit As New StringBuilder
Dim dr As wsMain.dsUser.tbCtlRow
sCrit = "some stuff for access to use"
'Startup Access Now
Dim AccessApplication As New Access.Application
'Make it visible ?should we do this later?
If Not AccessApplication.Visible = True Then
AccessApplication.Visible = True
End If
'Open app
AccessApplication.OpenCurrentDatabase(sFile)
'Call a function to start things running and pass in the user rights
that will be used to initalize everything
AccessApplication.Run("Main", sCrit.ToString)
Return FileMngr.Success

Catch ex As Exception
ErrLog(ex)
End Try
End Function


The msdn documentaion said to set the property (Copy Local) on the reference
to access to "False". When I did that, I get the following error:



System.IO.FileNotFoundException: File or assembly name Interop.Access, or
one of its dependencies, was not found.
File name: "Interop.Access"
at TransAct.ClientAppHelper.OpenApp()
at TransAct.frmMain.OpenClientApp() in
D:\nwis\Apps\LandMan\VS\TransAct\TransAct\frmMain. vb:line 553

=== Pre-bind state information ===
LOG: DisplayName = Interop.Access, Version=9.0.0.0, Culture=neutral,
PublicKeyToken=null
(Fully-specified)
LOG: Appbase = D:\nwis\Apps\LandMan\VS\TransAct\TransAct\bin\
LOG: Initial PrivatePath = NULL
Calling assembly : TransAct, Version=1.0.1887.28847, Culture=neutral,
PublicKeyToken=null.
===

LOG: Policy not being applied to reference at this time (private, custom,
partial, or location-based assembly bind).
LOG: Post-policy reference: Interop.Access, Version=9.0.0.0,
Culture=neutral, PublicKeyToken=null
LOG: Attempting download of new URL
file:///D:/nwis/Apps/LandMan/VS/TransAct/TransAct/bin/Interop.Access.DLL.
LOG: Attempting download of new URL
file:///D:/nwis/Apps/LandMan/VS/TransAct/TransAct/bin/Interop.Access/Interop.Access.DLL.
LOG: Attempting download of new URL
file:///D:/nwis/Apps/LandMan/VS/TransAct/TransAct/bin/Interop.Access.EXE.
LOG: Attempting download of new URL
file:///D:/nwis/Apps/LandMan/VS/TransAct/TransAct/bin/Interop.Access/Interop.Access.EXE.
</Exception>
</Errors>
<Errors d2p1:id="2" d2p1:TimeStamp="2005-03-02T16:10:40.6916071-06:00"
xmlns:d2p1="http://tempuri.org/dsErrorHandler.xsd">
<Exception>System.IO.FileNotFoundException: File or assembly name
Interop.Access, or one of its dependencies, was not found.
File name: "Interop.Access"
at TransAct.ClientAppHelper.OpenApp()
at TransAct.frmMain.OpenClientApp() in
D:\nwis\Apps\LandMan\VS\TransAct\TransAct\frmMain. vb:line 553

=== Pre-bind state information ===
LOG: DisplayName = Interop.Access, Version=9.0.0.0, Culture=neutral,
PublicKeyToken=null
(Fully-specified)
LOG: Appbase = D:\nwis\Apps\LandMan\VS\TransAct\TransAct\bin\
LOG: Initial PrivatePath = NULL
Calling assembly : TransAct, Version=1.0.1887.28847, Culture=neutral,
PublicKeyToken=null.
===

LOG: Policy not being applied to reference at this time (private, custom,
partial, or location-based assembly bind).
LOG: Post-policy reference: Interop.Access, Version=9.0.0.0,
Culture=neutral, PublicKeyToken=null
LOG: Attempting download of new URL
file:///D:/nwis/Apps/LandMan/VS/TransAct/TransAct/bin/Interop.Access.DLL.
LOG: Attempting download of new URL
file:///D:/nwis/Apps/LandMan/VS/TransAct/TransAct/bin/Interop.Access/Interop.Access.DLL.
LOG: Attempting download of new URL
file:///D:/nwis/Apps/LandMan/VS/TransAct/TransAct/bin/Interop.Access.EXE.
LOG: Attempting download of new URL
file:///D:/nwis/Apps/LandMan/VS/TransAct/TransAct/bin/Interop.Access/Interop.Access.EXE.



Thanks for any help anyone can offer.

The references above are not to the Office PIAs but to the generic interop assemblies that are
created at design-time by the Visual Studio .NET IDE when you add one of the Office applications to
your project.

You should be able to deploy those interop assemblies with your app.
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.