HandsOn Creating a User Account

1. Switch to the Visual Basic Editor window and insert a new module.

2. In the module's Code window, enter the CreateUserAccount procedure as shown below.

Sub CreateUserAccount()

Dim conn As ADODB.Connection

On Error GoTo ErrorHandler

Set conn = CurrentProject.Connection conn.Execute "CREATE USER GeorgeM fisherman 0302" ExitHere:

If Not conn Is Nothing Then

If conn.State = adStateOpen Then conn.Close End If

Set conn = Nothing Exit Sub ErrorHandler:

MsgBox Err.Number & ":" & Err.Description Resume ExitHere End Sub

Figure 22-1: After running the CreateUserAccount procedure in Hands-On 22-3, you should see a listing for the GeorgeM user account in the User and Group Accounts window (choose Tools | Security | User and Group Accounts).

0 0

Post a comment