Does not work TextBox.SetFocus (Access) method, throws run-time error 2465

Матвій Первак 0 Reputation points
2023-06-17T20:06:41.3766667+00:00

Essence: There is a form (fm_tbl_Rashod) and a subform (fm_tbl_Sostav_Rashod) related to each other through the main / subordinate field.

Using vba code, I change the fields in the table via recordset (everything is fine), but when validating and an error occurs (for example, if the field is empty or zero), I need to go to the field in the form to enter the required data. To do this, I use your help: hhttps://learn.microsoft.com/ru-ru/office/vba/api/access.textbox.setfocus where it is indicated that everything is simple, you need to do it like this: Forms! Employees! EmployeeID.SetFocus

However, I get an error: run-time error 2465! The vba code is executed from the button on the form, i.e. logically, the form remains active! How do I transfer focus to a form field from vba?

P.S. I wanted to write a question from Microsoft Edge, but when I try to write something in the form, the window freezes and reloads! I'm writing from Opera! How's that?!

Access
Access
A family of Microsoft relational database management systems designed for ease of use.
428 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.