Open Access From via Visual Basic

  • Thread starter Thread starter Diarmuid
  • Start date Start date
D

Diarmuid

Hi
I have an Access database, Invoices.mdb, secured with secured.mdw. In
there I have a form, frmInvoice. Each Invoice has a unique key, InvoiceID.

These Invoices are posted to a third party accounts package. In there, I can
have hooks, which will launch a Visual Basic program. So in my VB program,
I'd like to open my Access form, on a particular Invoice. Any suggestions?

Thanks
Diarmuid
 
Hi,

if you are using a vb program why not just open a recordset and pass the
data back to the accounts package?

to open the database and the correct invoice in VB
do something like

Dim appAccess as access.application
Set appAccess = CreateObject("Access.Application")
appaccess.OpenCurrentDatabase (invoices.mdb)

with appaccess
.docmd.openform "frmInvoices",,,,, wherecriteria
end with

the docmd object is available from the application reference within VB. The
code sample is pretty poor I know, but I'm pretty new at VB and can't
remember the exact syntax or the options for some of the commands
 
Caveat Number One: I don't currently have a secured app on this PC suitable
for testing this, so I'll have to leave it to someone else to address any
security-related complications that may exist.

Caveat Number Two: When someone says 'VB' I tend to assume, rightly or
wrongly, that they mean VB6 rather than VB.NET. I don't have VB6 installed
on this PC, so I tested using VBA in Excel.

Caveat Number Three: If you have to go through VB anyway, the more robust
and efficient solution would probably be to display the data in a VB form.
There's an old axiom that the weakest parts of any system are the links
between subsystems.

After all that, here's the code I tested in Excel ...

Private objAccess As Object

Public Sub AutomateAccess()

Set objAccess = CreateObject("Access.Application")

'Assumes MDB in same folder as workbook. Make sure you save the workbook
before running this.
objAccess.OpenCurrentDatabase ThisWorkbook.Path & "\test.mdb"
objAccess.Visible = True
objAccess.DoCmd.OpenForm "frmTest", , , "TestID = 2"

End Sub

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Thanks. Just one thing - how do I open a secured db through this code? I'm
using VB 6, the database is in Access 2000.

"Brendan Reynolds" <brenreyn at indigo dot ie> wrote in message
 
That's one of the things I meant in my previous post when I wrote "I'll have
to leave it to someone else to address any security-related complications
that may exist". The following KB article looks like it may be of some use
to you, but I'm not in a position to test it myself at the moment ...

http://support.microsoft.com/default.aspx?scid=kb;en-us;319397

BTW: If you just wanted to get at the data from the VB app, life would be a
lot simpler. You can set the workgroup, user name and password as properties
of the DAO DbEngine object before calling DbEngine.OpenDatabase().

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
I know what you meant. :) I wanted someone else who knew to answer!
It seems a bit strange to have to open the app, then use the code, but I'll
give it a shot as I can't think of any other way


Thanks
Diarmuid
 
Someone else may still answer, but sometimes, when people are busy, if they
see that a question has already been answered, they may not read it. If no
one else answers in this thread, it may be worth starting a new thread on
the specific question of automating a secured application.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Hi Diarmuid,

I am looking into this issue, I will try to pick up some experts on VB if
the following documents doesn't resolved your issue.

How To Automate a Secured Access Database Using Visual Basic
http://support.microsoft.com/?id=192919

There is no Automation method in the object model of Access that allows
Visual Basic to open a secured Access database without getting a prompt
requesting a username and password. However, it is possible to accomplish
this using the Shell command. This article demonstrates how to open a
secured Access database without getting a prompt.

Thank you for your patience and cooperation. If you have any questions or
concerns, don't hesitate to let me know. We are here to be of assistance!


Sincerely yours,

Mingqing Cheng
Microsoft Developer Community Support
 
Back
Top