S
S
safira1112019-06-14 22:16:36
Database
safira111, 2019-06-14 22:16:36

Why does it swear at the code for entering the database under different roles?

there is a database. it contains a table of employees (login, full name, position, department). It is understood that depending on the department in which the employee works, different forms will open. If an employee of the technical department enters. support, then the "ContributorsLayout" form opens, if the rest are "UsersLayout". This is implemented on the input form, where the login, full name are selected and when the ok button is pressed, the required form opens.
The problem is in the macro on the button. Swears at line 9.

Visual Basic
1. Private Sub Вход_Click()
2. Dim rst As DAO.Recordset
3. Set rst = CurrentDb.OpenRecordset("Сотрудники", dbOpenSnapshot) 'Сотрудники - указываем с какой таблицей будет работать сценарий
4. With rst
5. If IsNull(Me.Логин_поле.Value) Then 'Условие если поле выпадающего списка на момент клика пустое, то
6.       MsgBox "Ошибка входа! Выберите пользователя."
7.   Exit Sub
8.    Else
9.               .FindFirst ("Логин Like" & Me.Логин_поле.Value) 'Если поле не пустое, то производится поиск на соответствие с данными таблицы Сотрудники
10.
11.    DoCmd.Close 'Команда на закрытие текущей формы
12.    Select Case Сотрудники.Fields("Отдел").Value
13.      Case "Отдел технической поддержки"
14.       DoCmd.OpenForm "ИсполнителиМакет"
15.       Case Else
16.       DoCmd.OpenForm "ПользователиМакет"
17.     End Select
18.   End If
19.  End With
20. rst.Close
21. Set rst = Nothing
22. End Sub

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BasiC2k, 2019-06-15
@BasiC2k

And if the request returned an empty result - do you have such an option in your code?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question