Bobort
Bobort

Reputation: 3218

ALTER USER giving Syntax Error

I'm creating my own form to allow a user to change their password in a Microsoft Access database with user-level security, an *.mdb file. When I run the following VBA code, I get error 3293: Syntax error in ALTER TABLE statement.

CurrentDb().Execute "ALTER USER user PASSWORD NewPassword OldPassword"

I'm following the instructions found in the documentation. How do we change a password through VBA?

Upvotes: 2

Views: 839

Answers (1)

HansUp
HansUp

Reputation: 97101

CurrentDb.Execute is a DAO method, but ALTER USER must be executed from ADO.

Dim strSql As String
strSql = "ALTER USER user PASSWORD NewPassword OldPassword"
CurrentProject.Connection.Execute strSql

CurrentProject.Connection.Execute is an ADO method.

Upvotes: 3

Related Questions