Share via

Expression on Click error

Anonymous
2010-10-19T06:57:51+00:00

Hi Guys,

I have an application that is distributed as a runtime version, which connects to a MS SQL database.

One of my forms (Form A) has an option to open another form (form B) and modify some data. Form B has as part of its onClose event a line to requery data in Form A so any modifications will be updated.

When I develop and test locally in accdb format everything works fine and have no issue. However, when I convert to accde/accdr format I get an error message when I close form B :

"The expression on click you entered as the event property setting produced the following error: ApplicationName can't find the form '

frmOrderPlacement**' in macro expression or visual basic code.**

with the following supplementry error message:

This error occurs when an event has failed to run because Microsoft Office Access cannot evaluate the location of the logic for the event. For example, if the OnOpen property of a form is set to =[Field], this error occurs because Access expects a macro or event name to run when the event is fired.

This is the forms onClose event code:

Private Sub cmdClose_Click()

DoCmd.Close

DoCmd.SetWarnings False

Forms!frmOrderPlacement!frmOrderItems.Form!cboProducts.Requery

Forms!frmOrderPlacementEdit!frmOrderItemsEdit.Form!cboProducts.Requery

End Sub

I can confirm that both forms and combo boxes' exist

If anyone can suggest anything I would be most grateful.

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

4 answers

Sort by: Most helpful
  1. Anonymous
    2011-03-28T17:12:45+00:00

    Hi Guys,

    I have an application that is distributed as a runtime version, which connects to a MS SQL database.

    One of my forms (Form A) has an option to open another form (form B) and modify some data. Form B has as part of its onClose event a line to requery data in Form A so any modifications will be updated.

    When I develop and test locally in accdb format everything works fine and have no issue. However, when I convert to accde/accdr format I get an error message when I close form B :

    "The expression on click you entered as the event property setting produced the following error: ApplicationName can't find the form '

    frmOrderPlacement**' in macro expression or visual basic code.**

    with the following supplementry error message:

    This error occurs when an event has failed to run because Microsoft Office Access cannot evaluate the location of the logic for the event. For example, if the OnOpen property of a form is set to =[Field], this error occurs because Access expects a macro or event name to run when the event is fired.

     

    This is the forms onClose event code:

    Private Sub cmdClose_Click()

    DoCmd.Close

    DoCmd.SetWarnings False

    Forms!frmOrderPlacement!frmOrderItems.Form!cboProducts.Requery

    Forms!frmOrderPlacementEdit!frmOrderItemsEdit.Form!cboProducts.Requery

    End Sub

    I can confirm that both forms and combo boxes' exist

    If anyone can suggest anything I would be most grateful.

     

    I am re posting this question again, as I am still looking for the answer, and adding the following information, that hopefully might help resolve the issue.

    The subform 'frmOrderItems' and 'frmOrderItemsEdit' are both on a tab..is this relevant ?

    Also, this problem only occurs when I have converted the application from a Native A2007 format to ACCDE format for distribution.

    Would appreciate ANY suggestions with this.

    Was this answer helpful?

    8 people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2011-03-28T18:04:33+00:00

    Yes the contorls and form names are correct, I use the same for control and form name to try and avoid issues like this.

    I have now changed my code and have taken this off the Cmd close now and added it to the form I have open, 'AfterUpdate' event now, which has resolved the problem and re query's as required.

    Thanks for the speedy response

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2011-03-28T17:45:12+00:00

    First off, are you using the name of the subform control (control on the parent which houses the subform) and not the name of the subform itself?

    Second, why are you using DoCmd.SetWarnings False?  I don't get it why that would be necessary for a requery.  If you do this, you need to turn them back on again in the exit of the procedure or else you might miss something else important.

    Third, the name of frmOrderPlacement is correct?  No spaces, underscores, not named frmOrderPlacements, etc?  Also, I don't know if this would help but I would use

    Forms!frmOrderPlacement.frmOrderItems.Form.cboProducts.Requery

    but the subform control needs to be named frmOrderItems which it might not be, as you use the name of the subform control and not the subform name unless they share the same exact name.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2010-10-19T10:07:26+00:00

    You've got references to two separate forms frmOrderPlacement and frmOrderPlacementEdit. Are both those names correct? Are both those forms open?

    If you're still having problems, from your naming conventions, I'm assuming that form frmOrderItems is being used as a subform on form frmOrderPlacement, and that form frmOrderItemsEdit is being used as a subform on form frmOrderPlacementEdit. Check to ensure that the name of the subform control on form frmOrderPlacement is, in fact, frmOrderItems and that the name of the subform control on form frmOrderPlacementEdit is, in fact, frmOrderItemsEdit.


    Doug Steele, Microsoft Access MVP

    http://www.AccessMVP.com/djsteele (no e-mails, please!)

    Was this answer helpful?

    0 comments No comments