Solved

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

Posted on 2014-11-02
14
305 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
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

623 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