PDA

Click to See Complete Forum and Search --> : Open an MS Access Database from VB


chrisjk
Jul 18th, 1999, 12:53 AM
Hi, Does anyone know how I can physically open MSAccess itself with the database loaded from VB. You might say use the Shell function, but I need VB to supply a database password without the user seeing it, and I can't think how. I tried Sendkeys, but this can easily be overcome by giving Notepad focus....!!! Any ideas greatly received.

ScottF
Jul 18th, 1999, 06:08 PM
This is how you open a database in VB and pwd=PasswordName will open a password protected database where PasswordName is your Password.
Dim db as database
Set db = OpenDatabase _
("Database Path And Name", False, False, "MS Access;pwd=Password Name")
You can place the password in Window regisrty and use Api call to call back to a text box then use
Dim db as database
Set db = OpenDatabase _
("Database Path And Name", False, False, "MS Access;pwd=" & TextBox)

------------------

chrisjk
Jul 20th, 1999, 02:35 AM
That's great, but how can I convert it to use with VB6. VB6 doesn't recognise Database as a data type - it says 'User-defined type not defined' when you try and run it.

preeti
Jul 20th, 1999, 09:13 PM
Hi,

Add a reference to the Microsoft DAO 3.5 Object Library from the menu Project|References.

HTH,

Preeti

chrisjk
Jul 21st, 1999, 03:56 AM
Doh! Why didn't I think of that...! Thanks ScottF and Preeti.