Why does DoCmd.OpenForm stDocName, , , stLinkCriteria fail to open the form

Hi everybody,

I tried to adapt a old database to a new purpose.. I thought I have made small alterations, but one must have been fatal.
The job asked was to open a record sheet, (Formular) by clicking a button..
Now when I clck the button, I obtain an error message "Unable to open the form)
I can open the form manually
The form is related to a request which selects a series of records. This works also manually
The VBA stops precisely  on the followint sentence

DoCmd.OpenForm stDocName, , , stLinkCriteria

stDocName is known (the name of the form)  et stLinkCriteria ([Réf_Patient]=6   also

I removed the button and created a knew one.. Changed nothing

Any help would be greatly appreciated

Best regards
Jacques
Jacques WeissenburgerAss ProfAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
ReneD100Connect With a Mentor Commented:
If you have no idea where to start I'd suggest to go for the 'q&d' delete. MAKE A BACKUP/COPY OF THE FORM! Remove all controls and see if it works then. Then copy the form back from the backup, delete one half of the controls and try again. The form doesn't have to be operational, as long as you know what control causes the error.
0
 
Gustav BrockCIOCommented:
Can you open the form this way:

DoCmd.OpenForm "NameOfYourForm", , , "[Réf_Patient]=6"

?

/gustav
0
 
ReneD100Commented:
Put a messagebox before the openform command to make sure the values are correct.
'prev code
MsgBox(stDocName)
MsgBox(stLinkCriteria)
DoCmd.OpenForm stDocName, , , stLinkCriteria

Open in new window

0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Jacques WeissenburgerAss ProfAuthor Commented:
Thanks for that quick answer.
But I already checked that the values transmitted were correct
Nevertheless I put the code in place  and the answer in the MsgBox where those expected
Gestion des réunions RCP
[Réf_Patient]=6

When I try to lauch the form directly
  I am asked for a Réf_Patient
  I put the right number (6)
and this also produced an error
  it is written in french  : a communication error between MSAccess and OLE servopr or Control ActiveX

The Help button displays the following message  (sorry : in french)

  Cette erreur se produit lorsqu’un événement ne peut pas être exécuté parce que l’emplacement de la logique correspondante est introuvable. Par exemple, si la propriété OnOpen d’un formulaire est définie sur la valeur =[Field], cette erreur se produit, car un nom de macro ou d’événement doit être exécuté lorsque cet événement se produit.


Does that help?
0
 
Gustav BrockCIOCommented:
> When I try to lauch the form directly
> I am asked for a Réf_Patient

If so, [Réf_Patient] is misspelled or an unknown field of the source of the form.

/gustav
0
 
ReneD100Commented:
The error just indicates something goes wrong opening the form, so that doesn't help much.  [Réf_Patient] does not have to be misspelled because that could be a variable in the underlying query of the form.
"a communication error between MSAccess and OLE server or Control ActiveX" could indicate that one of the controls is not working properly. Make a copy of the form and remove any non-native Access controls (the ActiveX controls) and see what happens then.
0
 
Gustav BrockCIOCommented:
Rene is right. [Réf_Patient] is a variable in the underlying query of the form.

/gustav
0
 
Jacques WeissenburgerAss ProfAuthor Commented:
How can I find these non-native Access controls?

The form is a very complex one, reason why I didn't want to rewrite it.
The form originally contained two subforms. I removed both subforms and since that I have the openform trouble.. (I removed also all addressings to these subforms of course)

Does this help
0
 
Jacques WeissenburgerAss ProfAuthor Commented:
I did this and even with a blanck empty form, I received the same message

So I went back to a previous version, with one subform (and not the original two)..
This  one worked a little better.
The form opened but with the message

Microsoft Access can't find the field '|1' referred to in your expression

This is new and probably related to the subform which stays gray (nothing highlighted)
0
 
Jacques WeissenburgerAss ProfAuthor Commented:
Here is the point where it stops :

It is a subroutine where an icone is modified the flip/flop way to allow or not to modify the content of the form

Sub ChangeLockForm(Flag As Boolean)

If Flag = True And NewRecordFlag = False Then
    If MsgBox("Are you sure you want to modify that form ?", _
                     vbYesNo + vbCritical, "Vérification") = vbNo Then
        Exit Sub
    Else
        Me.Renseignement.SetFocus
    End If
End If

Me.Form.AllowEdits = Flag
Me.[Gestion des réunions RCP].Form.AllowEdits = Flag
Me.[Germes isolés].Form.AllowEdits = Flag
Me.[Gestion des réunions RCP].Form.AllowDeletions = Flag
Me.[Gestion des réunions RCP].Form.AllowAdditions = Flag

If Flag = True Then
BoîteloCK.Visible = False
BoîteUnlock.Visible = True
Else
BoîteloCK.Visible = True
BoîteUnlock.Visible = False
End If

End Sub
0
 
Jacques WeissenburgerAss ProfAuthor Commented:
Sorry it blocks exactly here

Me.Form.AllowEdits = Flag
Me.[Gestion des réunions RCP].Form.AllowEdits = Flag  <++ here
Me.[Germes isolés].Form.AllowEdits = Flag
0
 
ReneD100Commented:
That code looks very innocent to me. But what intrigues me more is this: "I did this and even with a blanck empty form, I received the same message"
So you deleted all the controls and then it still happened? Then it could be something in the underlying query/source that is incorrect.  The error "Microsoft Access can't find the field '|1' referred to in your expression" also suggests that. Have you tried your original form without the underlying query?
0
 
Jacques WeissenburgerAss ProfAuthor Commented:
I went one step further

Now I can open the form and see the right name..
 The path is the following :
   I open an identification form where I select a name and then click a button which closes that form and opens a new one..connected to a fliter query. That new form allowas me to travel between all the records sharing the same name..
  That form has also a subForm  connected to a list of bacteria

Now the display is OK except that I cannot modify any field. Any click on every button is followed by the same error message as previously   "Microsoft Access can't find the field '|1' referred to in your expression"

And the subform is grey.. I can circulate between the bacteria, but I cannot select any..

It looks like the Form and the subform are only on a display mode...
0
 
Jacques WeissenburgerAss ProfAuthor Commented:
Rene was rigth. A field was not recognized
Took me a while to find it but I finally was abble to connect everything

Thanks
0
All Courses

From novice to tech pro — start learning today.