Solved

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

Posted on 2014-11-02
14
278 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 49

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
 
LVL 49

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 49

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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

INTRODUCTION The purpose of this document is to demonstrate the Installation and configuration of the Data Protection Manager product. Note that this demonstration was prepared on the basis of Windows OS is 2008 R2 and DPM 2010. DATA PROTECTI…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now