Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2021
    Posts
    4

    No Runtime Error-forms or VBA Compile Error when running Function via Button_Click in Form


    EDIT: Solution: The check-box "Use Access Special Keys" under File->Options->Current Database was not check. When checked, everything worked as expected!

    Hi all,

    I have an Access-application where I no longer get any automatic Compile Errors when running VBA-code via the Buton_Click-event in a form. Se the image below for example, when I press the button in the form, the button reacts in the GUI, but then nothing else happens.

    Click image for larger version. 

Name:	no error.png 
Views:	9 
Size:	62.6 KB 
ID:	46490

    I have to open the VBA-windows and choose Debug/Compile Database to see the error. Previously the VBA-window would open automatically and show the error.

    Click image for larger version. 

Name:	error_shown.png 
Views:	9 
Size:	10.0 KB 
ID:	46491

    If I create a new database with one form and one line of VBA-code, I get the expected behavior, the VBA-window opens automatically and shows the error. Therefore I guess the problem is a setting somewhere within the database itself, and not within the Access-application.

    Click image for larger version. 

Name:	error new db.png 
Views:	9 
Size:	44.3 KB 
ID:	46492

    Also, in the same "problematic" Access-application I will not get prompted any Rutime Error-dialogues (not the standard, nor any by an ErrorHandler in the code). However, when opening the Access-database on another computer (same Windows 10- and Access-version, O365 Version 2102) I will get the Runtime Error-dialogues (but not the automatic the VBA Compile Error described above).

    I've tried activating warnings with the line "DoCmd.SetWarnings True", but with no difference.

    Is there any setting, either in the client or within the database itself that can give this problem? Would really appreciate any help with this since it's quit cumbersome to develop the application on my machine due to these problems!
    Last edited by byggarebob123; 10-27-2021 at 09:00 AM.

  2. #2
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    There are various options that are in the VBA editor.
    Goto to Tools¬Options
    Click image for larger version. 

Name:	VBA_Editor_Tools_Options.png 
Views:	9 
Size:	23.0 KB 
ID:	46493


    And under the general tab, see what is selected against a working database on another machine.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    Join Date
    Oct 2021
    Posts
    4
    Quote Originally Posted by Minty View Post
    There are various options that are in the VBA editor.
    Goto to Tools¬Options
    Click image for larger version. 

Name:	VBA_Editor_Tools_Options.png 
Views:	9 
Size:	23.0 KB 
ID:	46493


    And under the general tab, see what is selected against a working database on another machine.
    Thank you for the quick reply. Sadly, no difference what so ever between a working DB and my problematic one. The exact same settings on all four tabs.

  4. #4
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    Hmm, have you tried an office repair.
    Or are there any pending updates. I've had some really weird errors when an update hasn't completed.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  5. #5
    Join Date
    Oct 2021
    Posts
    4
    Quote Originally Posted by Minty View Post
    Hmm, have you tried an office repair.
    Or are there any pending updates. I've had some really weird errors when an update hasn't completed.
    No pending updates (Updates managed by system administrator) and I've had this problem a couple of months where I know our Office-suite has been updated. Yesterday I tried a complete uninstall/install, but the problem still resisted.

  6. #6
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    What if you open the database with the shift key - bypassing all code.
    Then open your demo form in the troublesome database and see what happens?

    Perhaps some setting is being changed somewhere in the opening of your database.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  7. #7
    Join Date
    Oct 2021
    Posts
    4
    Quote Originally Posted by Minty View Post
    What if you open the database with the shift key - bypassing all code.
    Then open your demo form in the troublesome database and see what happens?

    Perhaps some setting is being changed somewhere in the opening of your database.
    EDIT2: When comparing the settings under Access Options->Current Database of my problematic DB as a new DB I found a difference, the setting "Use Access Special Keys". When activating, I now get auto-compile errors, YES!

    Hi Minty!

    I did the following, shift key and opening the problematic DB. Created a new form within the DB, added button and an erroneous VBA-code line. Now when I press the button I get the expected result with automatic VBA-debugging, woho!

    I have a setting that opens the form "Inställningar" (Swedish for Settings) on start-up, but even when I change that to "none", there seems to be some code running on start-up since it still doesn't work without holding the shift key on startup.

    Click image for larger version. 

Name:	2021-10-27_16-22-21.png 
Views:	7 
Size:	19.3 KB 
ID:	46494

    I've looked through my VBA Code and can't find anything running on start-up from there. Any suggestions on where I should look?

    EDIT: I have no Marcos (the list is emtpy when I click Database Tools->Macro)

  8. #8
    Micron is online now Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    The first situation to eliminate is that the code actually runs. If you knew and said that, I missed it.
    The second, in a situation like this is to decompile the db. Plenty of web info on how to do that. The reason for doing so is that the code you see in the editor might not actually be the compiled version, and for whatever reason, it won't compile as written. So you decompile the whole thing then re-compile it as the info will show. That usually fixes this problem. The last thing I'd do for a situation where a single db behaves like this and the others don't is to do any Office repair/reinstall.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 5
    Last Post: 02-21-2017, 01:58 PM
  2. Compile Error: Sub/Function not defined
    By TheKillerMonkey in forum Programming
    Replies: 12
    Last Post: 04-18-2016, 01:48 PM
  3. Compile Error Sub or function not defined
    By Ray67 in forum Reports
    Replies: 3
    Last Post: 07-02-2012, 04:11 PM
  4. Compile error: code or function not defined
    By GeorgeBrown in forum Access
    Replies: 1
    Last Post: 09-19-2011, 10:25 AM
  5. Compile error. Sub of function not defined
    By plavookins in forum Reports
    Replies: 7
    Last Post: 04-22-2011, 10:15 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