Results 1 to 9 of 9
  1. #1
    KCC47 is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Feb 2013
    Posts
    77

    Error Message When Closing a Form w/ Macro

    I keep getting this error message when closing a form with a macro: "The expression you entered has a function name that Microsoft Access can't find." It is located in the Application_Log_Frm when selecting a hyperlinked Application_ID and then closing the form that was opened with the Application_Close_CommandButton.



    I'm thinking it has something to do with the macro used to open that form for the Application_ID.

    Application_Log_Db.zip

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    You open a form with Application_Close_CommandButton?

    I get error message trying to open the VBA editor.

    "The database cannot be opened because the VBA project contained in it cannot be read. The database can be opened only if the VBA project is first deleted. ..."

    Okay, will stay away from VBA editor. You don't have any code in there anyway, right?

    I don't use macros, only VBA. This could take a while.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    thebigthing313 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    119
    In the Macro, are you closing directly from the macro or are you calling a procedure?

    If you are calling a procedure, make sure that it is public and a Function, even if there is no return value. RunCode requires a function name (a requirement also being that the function name doesn't coincide with a module name).

  4. #4
    KCC47 is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Feb 2013
    Posts
    77
    My skills at VBA are not very advanced.

    If you open the Application_Log_Frm, select one of the hyperlinked records in the Application ID column. It will then open the Application_Search_SubFrm for that matching Application_ID. When you attempt to close that form you get that error unless you change something on the form.

    If you have a better suggestion to open a record for editing from a log, please let me know. I'll need step by step instructions for any VBA as I don't understand how to use it very well.

    I've deletd some old forms, so I believe that would resolve your error messages opening the database.

    Application_Log_Db.zip

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    Okay, that helped. There is VBA code.

    Application_Log_Frm could be a single form instead of form/subform. Can set the form as Continuous and arrange controls to look like datasheet.

    There is a wizard to convert embedded macros to VBA.

    Why does Application_Search_SubFrm have SubFrm in its name?

    The Save argument of Close action should probably be set to No. This Save argument has nothing to do with saving the record, it concerns saving changes to object design. Code can dynamically change properties and Save Yes could cause those changes to be saved.

    The error happens even if the form X close is used, so this has nothing to do with the Close button event (macro or VBA). The error does not happen if the form is manually opened from the Navigation pane.

    The macro has a syntax error.

    If NotIsNull([Application_ID]) Then

    Needs a space after Not

    If Not IsNull([Application_ID]) Then

    New error:

    "Microsoft Access can't find the field 'ResourceSource' referred to in your expression."

    You have a DMax expression:

    Nz(DMax("[Application_ID]",[Form].[ResourceSource]),0)

    Change Resource to Record.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    KCC47 is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Feb 2013
    Posts
    77
    I've made some of the corrections you mentioned namely the space after Not, but now I am getting a new error.

    Microsoft Access can't find the field 'ResourceSource' referenced to in our expression.

    CurrentID, Nz(DMax("[Application_ID]",[Form].[ResourceSource]),0)

    Application_Log_Db.zip

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    Apparently I edited my previous post after you read it. Review again.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    KCC47 is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Feb 2013
    Posts
    77
    Gotcha. That appears to be working now. Thank you.

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    Do you really want to use DMax on form RecordSource? What if the form has filter applied? What value are you really looking for?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 8
    Last Post: 06-09-2014, 09:26 AM
  2. Replies: 15
    Last Post: 11-01-2013, 03:24 PM
  3. Replies: 14
    Last Post: 06-06-2012, 12:50 PM
  4. Replies: 5
    Last Post: 12-22-2011, 01:12 PM
  5. Replies: 3
    Last Post: 07-04-2011, 02:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums