Re: Select a specific instance of Access

From: John Nurick (j.mapSoN.nurick_at_dial.pipex.com)
Date: 07/22/04


Date: Thu, 22 Jul 2004 22:19:18 +0100

Hi Andrew,

If the only reason you're using Shell() is to pass the username and
password so you can get at the data, you can do it with code like the
sample procedure below. (It was written for VBScript but is easily
modified for VBA.)

If on the other hand you actually need to automate the instance of
Access, see this article for a way of getting hold of the instance yuo
need:
How To Automate a Secured Access Database Using Visual Basic
http://support.microsoft.com/default.aspx?scid=kb;EN-US;192919

  Dim dbE 'As DAO.DBEngine
  Dim dbW 'As DAO.Workspace
  Dim dbD 'As DAO.Database
  Dim rsR 'As DAO.Recordset
  
  Set dbE = CreateObject("DAO.DBEngine.36") 'VBS, late binding
  'Set dbE = New DAO.DBEngine 'VB/VBA, early binding

  dbE.SystemDB = "C:\temp\xx\secured.mdw"
  Set dbW = dbE.CreateWorkspace("Test", "Amoss", "Elsie")
  Set dbD = dbW.OpenDatabase("C:\temp\xx\test.mdb")
  
  Set rsR = dbD.OpenRecordset("Query1")
  With rsR
    MsgBox .Fields(0).Value 'demo only
    'Add a record:
    ' .AddNew
    ' .Fields(FileName).Value = strResultsFileName
    ' ...other fields if needed...
    ' .Update
  End With
  
  rsR.Close
  dbD.Close
  dbW.Close
  Set rsR = Nothing
  Set dbD = Nothing
  Set dbW = Nothing
  Set dbE = Nothing

On Thu, 22 Jul 2004 07:45:12 -0700, Andrew Jones <Andrew
Jones@discussions.microsoft.com> wrote:

>I have a module in an access 2000 database that uses a shell
command to open another database (I use the shell command to automate
the username and password since we are on a workgroup security file -
KB192919). The database opens but when I use the getobject function, it
selects the first instance of access, but I want it to select the one I
just opened with the shell command.
>Any ideas on how to set the focus to a specific instance of access?
>
>Thanks,
>Andrew

--
John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.


Relevant Pages

  • Re: How to set /etc/fstab again after system has started
    ... on a Linux desktop somewhere. ... that shell prompt become somewhat more important. ... For me, the big one is "select", which allows any shell command or alias ...
    (comp.os.linux.misc)
  • Re: How to set /etc/fstab again after system has started
    ... on a Linux desktop somewhere. ... that shell prompt become somewhat more important. ... For me, the big one is "select", which allows any shell command or alias ...
    (comp.os.linux.misc)
  • Re: Files launched w/ Followhyperlink open but not visible
    ... It appears that you got a useful answer on using Shell. ... New Window argument. ... it opens an instance of the software registered ... Yes I have considered the Shell command. ...
    (comp.databases.ms-access)
  • RE: Directories into arrays, again.
    ... >>> And a reason why using a shell command to copy a file is a bad idea. ... Well, I boiled the script down to essentials before posting it, ... only use the piped open form when you need to communicate ...
    (perl.beginners)
  • Re: [OT] Vim Question
    ... How do you invoke a shell command and pass arguments to said command? ... foo bar foobar barfoo a b c ...
    (comp.lang.ruby)