Solved

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

Posted on 2014-11-02
14
289 Views
Last Modified: 2014-11-15
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
0
Comment
Question by:weissenb
  • 7
  • 4
  • 3
14 Comments
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 40418907
Can you open the form this way:

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

?

/gustav
0
 
LVL 5

Expert Comment

by:ReneD100
ID: 40418917
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
 

Author Comment

by:weissenb
ID: 40418969
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 50

Expert Comment

by:Gustav Brock
ID: 40418996
> 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
 
LVL 5

Expert Comment

by:ReneD100
ID: 40419115
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
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 40419118
Rene is right. [Réf_Patient] is a variable in the underlying query of the form.

/gustav
0
 

Author Comment

by:weissenb
ID: 40419205
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
 
LVL 5

Accepted Solution

by:
ReneD100 earned 500 total points
ID: 40419219
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
 

Author Comment

by:weissenb
ID: 40420483
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
 

Author Comment

by:weissenb
ID: 40420520
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
 

Author Comment

by:weissenb
ID: 40420529
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
 
LVL 5

Expert Comment

by:ReneD100
ID: 40421469
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
 

Author Comment

by:weissenb
ID: 40422503
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
 

Author Closing Comment

by:weissenb
ID: 40444629
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

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question