I make a form with authorization, in akses. This form contains a field with a login (drop-down list) and a field with a password (an ordinary text field), as well as an OK and Exit button (I will omit the text labels). The data for verification is taken from another database, the Operators table, in which there are fields (name, login, password). I have imported a table into this database (it cannot be copied to the database - according to the conditions of the assignment). Use standard methods of protection (DB passwording, etc., is also impossible). By Guglezh, I got to the point that the Ok button handler needed to hang up, roughly speaking, the VBA code, which, when clicked, does all the magic, and also launches the necessary form.

So far, I have not dealt with VBA. Found on the Internet this solution

Private Sub Кнопка8_Click() Dim rst As DAO.Recordset Set rst = CurrentDb.OpenRecordset("Operator") With rst .FindFirst ("Логин=" & Me.Комбинированная11.Value) If .NoMatch Then MsgBox "Данный логин отсутствует в БД" Exit Sub Else If Me.Поле6.Value <> .Fields("Пароль").Value Then MsgBox "Пароль не правильный или не соответствует имени пользователя" Exit Sub End If End If End With rst.Close Set rst = Nothing End Sub 

After that, when the form starts, a message pops up.

invalid use of Me keyword

"Combined11" - a field with a drop-down list with logins on the form.

"Field6" - password field

"Password" - the names of the column with passwords in the table Operators

"Button8" - the button on which actually becomes a "tyk", I hang a handler on it.

  • Comments are not intended for extended discussion; conversation moved to chat . - PashaPash

1 answer 1

Most likely you have the code in a regular module, and not in a form module, so Me , which should indicate a non-current form, does not exist in this context. You need to transfer the code to the form module.

Secondly, because You need to find the text in the database, then in the request you need to put the value of the drop-down list in quotes.

And yet, in VBA, the function parameters, if its result is not assigned to anything, can be specified without parentheses (if I'm not mistaken, in earlier versions of the office, the translator swore to use them without assignment).

In the end, you just need to change the string

 .FindFirst "Логин = '" & Me.Комбинированная11.Value & "'"