testn1
asked on
vbs/access file
Hi,
how do i create a vbs or exe? that would create a new MS Access file in a certain directory for a
certain user with her password and it should work on an OS level for the
version of access users have instaled in their local boxes?
how do i create a vbs or exe? that would create a new MS Access file in a certain directory for a
certain user with her password and it should work on an OS level for the
version of access users have instaled in their local boxes?
Sub CreateDatabase(DatabaseNam e As String, Password As String)
'Ref:
' http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odeopg/html/deovropeningaccessdatabasebyusingado.asp
' http://support.microsoft.com/?kbid=304915
Dim objCat As Object 'New ADOX.Catalog
Dim objConn As Object 'ADODB.Connection
Dim strAlter As String
' create the database
Set objCat = CreateObject("ADOX.Catalog ")
objCat.Create "Provider=Microsoft.Jet.OL EDB.4.0; Data Source=C:\" & DatabaseName & ";Jet OLEDB:Engine Type=5"
Set objCat = Nothing
' set the password
Set cn = CreateObject("ADODB.Connec tion")
objConn.Mode = adModeShareExclusive 'opens in exclusive mode
objConn.Open "Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\" & DatabaseName & ";Uid=;Pwd="
strAlter = "ALTER Database Password " & Password & "``"
objConn.Execute strAlter
Set objConn = Nothing
End Sub
'Ref:
' http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odeopg/html/deovropeningaccessdatabasebyusingado.asp
' http://support.microsoft.com/?kbid=304915
Dim objCat As Object 'New ADOX.Catalog
Dim objConn As Object 'ADODB.Connection
Dim strAlter As String
' create the database
Set objCat = CreateObject("ADOX.Catalog
objCat.Create "Provider=Microsoft.Jet.OL
Set objCat = Nothing
' set the password
Set cn = CreateObject("ADODB.Connec
objConn.Mode = adModeShareExclusive 'opens in exclusive mode
objConn.Open "Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\" & DatabaseName & ";Uid=;Pwd="
strAlter = "ALTER Database Password " & Password & "``"
objConn.Execute strAlter
Set objConn = Nothing
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Set appAccess = CreateObject("Access.Appli
appAccess.NewCurrentDataba
i am unsure about setting the password, etc..
This will create an Access DB for the version of Access that is installed on the users machine.
this also means, No Access, No Database.