I have not yet tried running this code in Access 97. It was
ported from Access 2.0. It fails to compile, failing on the line
xxxxxxxxxxxxxxxxxxx
Function MakeUsersFromTable(TableName As String, GroupName As String)
'************************************************* ********************
' Accepts TableName, GroupName
'
' Returns "Users Added" if successful. Otherwise, "Users Not Added".
'
' The object here is to have a table with three fields feed a data
' stream to this procedure. The three fields represent user name,
' personal id (PID) and password. The procedure churns out a new user
' for each record in the table.
'************************************************* ********************
On Error GoTo Err291
Dim MyWorkSpace As Workspace, MyDatabase As Database
Dim MyRecordSet As Recordset, MyUser As USER, MyGroup As Group
Set MyWorkSpace = DBEngine.Workspaces(0)
Set MyDatabase = DBEngine.Workspaces(0).Databases(0)
Set MyRecordSet = MyDatabase.OpenRecordset(TableName, DB_OPEN_DYNASET)
MyRecordSet.MoveFirst
Do Until MyRecordSet.EOF
Set MyUser = MyWorkSpace.CreateUser(MyRecordSet!UserName,
MyRecordSet!PID, MyRecordSet!Password) ' name, PID and ZLS password
MyWorkSpace.Users.Append MyUser
Set MyUser = MyWorkSpace.CreateUser(MyRecordSet![UserName]) ' not
knowing this line needed 2B here cost me an entire day!
MyWorkSpace.Groups(GroupName).Users.Append MyUser
MyRecordSet.MoveNext
LoopMark:
Loop
MakeUsersFromTable = "Users Added"
Exit291:
Exit Function
Err291:
If Err = 3390 Then
MsgBox MyRecordSet.UserName & " is already a user! Make a note of
it.", 64, "User Exists!" & " - " & MyApp$ & ", rev. " & MY_VERSION$
GoTo LoopMark ' could put Resume Next in here
End If
MakeUsersFromTable = "Users Not Added"
MsgBox Error$ & Err, 16, MyApp & ", version " & MY_VERSION$
GoTo Exit291
End Function
It fails saying "Method or data member not found when compiling
MsgBox MyRecordSet.UserName (under Err291: label).
Is this easily fixed?