Cannot find the referenced form

我的未来我决定 提交于 2020-01-05 04:16:09

问题


When I click on the Create New Form button below, I get the following runtime error 2450 dialog box:

When I click on the debug button, it gives me the following:

The main form is called FindClientsNavigation. The "Create New Form" button in the ListOfForms subform is supposed to cause the NavigationSubForm to replace the ListOfForms form with a new CommunicationForm so that the user can enter information from a new form for the Client with the specific Client ID that is available in the txtClientID textbox, which you can see in the top of the FindClientsNavigation form in my first image above.

How do I alter the code above so that it loads a new CommunicationForm in the NavigationSubForm? And how do I get that new CommunicationForm to have the ClientID stored in it, so that submitting the form will allow the form to be saved with reference to the specific ClientID?


回答1:


The SourceObject needs to be set to a string, which is the name of the form to use:

.SourceObject = "CommunicationForm"

[Note that Forms is the collection of open forms so you cannot use this to refer to a form in the Navigation Pane - unless you know that this form is open.]

You can use the Client ID (on the main form) for this subform, but there are a number of ways to do this and it depends on your specific requirement:

  • The subform could be based on a query that refers to the textbox (perhaps txtClientID) on the main form. This is one of the simpler approaches.
  • You could dynamically set the RecordSource for the subform, using a WHERE clause that refers to the Client ID (similar to the above approach).
  • You could apply a Filter to the subform, so that it only displays the single record for the Client ID.


来源:https://stackoverflow.com/questions/18903606/cannot-find-the-referenced-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!