security - Emulating a SHIFT key press when using VBA to open an ms-access database secured by an mdw file? -


i want run recursively through directory of *.mdb files , search them see ones have specific linked table.

these files secured using several *.mdw files. did not write of them, maintainer.

i've found way this, it's interactive; need non-interactive; since of these *.mdbs i'm searching use autoexec macro.

from understand executing autoexec macro can avoided if 1 holds shift key while opening them; use command line in my macro open these files, , there doesn't seem way hold shift key.

i've found example, which allow hold down shift key avoid autoexec macro (see bypassing startup settings when opening database), does not allow unlock database *.mdw file, because opencurrentdatabase() method not have parameter *.mdw file

if goal check whether db file contains specific linked table, can use ado openschema method. approach, don't need open db file in access application session, autoexec macro not run.

below example using late binding. left comment notes in case prefer binding. change provider if access version older 2007.

since you're using access user-level security, have adapt connection string include path mdw , supply access security user name , password. here example connection string (using jet 4 provider) connectionstrings.com. split single-line string on semicolons readability:

provider=microsoft.jet.oledb.4.0; data source=c:\mydatabase.mdb; jet oledb:system database=system.mdw; user id=myusername; password=mypassword;  public function haslinkedtable(byval pdb string, _         byval ptable string) boolean      const adschematables = 20&     dim cn object ' adodb.connection     dim rs object ' adodb.recordset     dim strconnect string     dim blnreturn boolean      strconnect = "provider=microsoft.ace.oledb.12.0;" & _         "data source=" & pdb & ";"     'set cn = new adodb.connection     set cn = createobject("adodb.connection")     cn.open strconnect      set rs = cn.openschema(adschematables)     rs         while not .eof             if !table_name = ptable , !table_type = "link"                 'debug.print !table_name, !table_type                 blnreturn = true                 exit             end if             .movenext         loop         .close     end     cn.close     set cn = nothing     haslinkedtable = blnreturn end function 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -