There are two forms. One of them displays data from the table (full name, login, login date, etc.), all fields are locked for editing. With a double click, another form should open in which the fields on which there was a double click are open for editing. I in one form tried to hang up the following code. For example, the field "name" contains the following code:

Private Sub ФИО_DblClick(Cancel As Integer) Dim stDocName As String Dim stLinkCriteria As String stDocName = "Main2" stLinkCriteria = "[ФИО=]" & "'" & Me![ФИО] & "'" DoCmd.OpenForm stDocName, , , stLinkCriteria DoCmd.Close acForm, "Main" End Sub 

but it does not work, it produces a syntax error, the statement in the query expression is '[Full name =]' LoremIpsum ". When corrected as follows:

 stLinkCriteria = "[ФИО]=" & "'" & Me![ФИО] & "'" - открывается просто пустая форма. 

How to implement data transfer, at least in which direction to dig?

  • stLinkCriteria what is this parameter? OpenArgs? - Anatol
  • Add to the question the code for opening and loading the form Main2 - Anatol
  • @Anatol something you have confused me .. what does the opening code mean? I haven’t yet prescribed any mein2. stLinkCriteria - as I understand it - a parameter that sets the filter criteria and passes it further into the form that opens. - anton

1 answer 1

just an empty form opens

Well, check its RecordSource - you will immediately see that it is not so, why records are not displayed on the form. Well, check its properties — for example, whether the DataEntry property is set ...

And you can also pass the required parameters, for example, through the public variables of the form module — set their values ​​to the required ones, and the form already uses them for display for customization. In this case, of course, it will not be possible to use DoCMD, it will be necessary to explicitly load the form, display it and transfer focus to it using various Load, Show, etc. But this is more correct, in fact, besides, it can load not an abstract form, but a concrete copy of its class.

  • But it is possible a brief educational program on how to use a record set, for the first time I hear about it - anton
  • In this task, it is not necessary to use it from the word "in general". And nobody has said anything about record sets here yet ... - Akina
  • well, what about then? - anton
  • and if I use OpenArgs? - anton