?
Solved

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

Posted on 2014-11-02
14
Medium Priority
?
313 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
  • 3
14 Comments
 
LVL 51

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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 51

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 51

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 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

719 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