mloucel
Active member
- Local time
- Yesterday, 23:42
- Joined
- Aug 5, 2020
- Messages
- 388
Hello All:
I decided to add a password to my database to avoid people getting their hands in my tables, I ask Google AI and Grok how to create code to open the database with that password and gave me this:
GROK:
and Google:
Which one of those codes is better or is there a better way?
I decided to add a password to my database to avoid people getting their hands in my tables, I ask Google AI and Grok how to create code to open the database with that password and gave me this:
GROK:
Code:
Sub OpenProtectedDatabase()
Dim appAccess As New Access.Application
' Open the database with the password
appAccess.OpenCurrentDatabase _
Filepath:="C:\YourPath\Auth.accdb", _
Exclusive:=False, _
bstrPassword:="Athoriz"
' Make it visible to the user
appAccess.Visible = True
' Optional: Clean up reference later when done
' Set appAccess = Nothing
End Sub
and Google:
Code:
Sub OpenAuthDatabase()
Dim accApp As Object
Dim dbPath As String
' Set the full path to your "Auth" database
dbPath = "C:\YourPath\Auth.accdb"
' Create a new instance of Access
Set accApp = CreateObject("Access.Application")
accApp.Visible = True
' Syntax: .OpenCurrentDatabase (filepath, exclusive, password)
accApp.OpenCurrentDatabase dbPath, False, "Athoriz"
End Sub
Which one of those codes is better or is there a better way?