Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8287045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:55:52+00:00 2026-06-08T11:55:52+00:00

Whilst updating my code this morning, I caused an error – I replaced a

  • 0

Whilst updating my code this morning, I caused an error – I replaced a function with a string but forgot to take out the parenthesese that followed, which caused the code not to run.

However, this didn’t trigger my error handling code, so it didn’t report the error and it took me ages to find it by stepping through the code.

Code below:

Private Sub Form_Close()

On Error GoTo ErrHandler

'Update to say the user is no longer logged in

        DoCmd.SetWarnings False
        DoCmd.OpenQuery "Last Logged Out"

'Backup data
If (strNameChecker <> "workshop.accdb") Then

        strBackupUser = Nz(GetFullName(), "default")
        strFriendlyNow = Replace(Now(), "/", "-")
        strFriendlyNow = Replace(strFriendlyNow, ":", "-")
        strNewFileName = "F:\Data\Central\Marketing\Databases\Prospects Database\Auto-Backups\TargetDBData - backed up by " & strBackupUser() & " on " & strFriendlyNow & ".mdb"
        BackupProspects "F:\Data\Central\Marketing\Databases\Prospects Database\TargetDBData.mdb", "" & strNewFileName & ""
        sSql = "INSERT INTO [Backup to Delete] ([Version Number]) SELECT '" & strNewFileName & "' AS Expr1;"
        DoCmd.RunSQL sSql


'Delete the temporary version of the front end.
        DoCmd.OpenQuery "Update - Version Shutdown"
        DoCmd.SetWarnings True
        Application.FollowHyperlink "F:\Data\Central\Marketing\Databases\Prospects Database\Prospects Database Shutdown.accdb"

End If

Exit Sub

ErrHandler:
DoCmd.SetWarnings True
MsgBox "The database has generated an error. Please contact the database administrator, quoting the following error message: '" & Err.Description & "'", vbCritical, "Database Error"

End Sub

The error is caused by the two parenthese after strBackupUser about halfway down the code – delete these and the code works fine – but why doesn’t this error trigger the error handling?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T11:55:53+00:00Added an answer on June 8, 2026 at 11:55 am

    You don’t appear to have Option Explicit at the top of your module. As a result, all the string variables will be silently declared as Variant. I’m not sure what the compiler will make of the expression strBackupUser(), I guess it will attempt some kind of horrible late-bound object or array access.

    I suggest that you add Option Explicit first, then explicitly declare all your variables as strings, then see whether you get a compiler error.

    Here is a useful “war story” that illustrates how and why to use it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Whilst working on some generally horrible Javascript code this morning, I came across the
Whilst reading through K&R, I came across the integer to string function. I gave
Whilst reviewing some Qt C++ code I came across this: class Foo { Q_OBJECT
Whilst running test code from this question and fiddling with the JVM's thread stack
Whilst refactoring some code I came across some getter methods that returns a std::string.
Whilst reading jQuery Cookbook (Oreilly) last night I came across an each function that
Whilst I'd love to solve this problem in python, I'm stuck in Delphi for
Whilst looking for a B-V color index to temperature conversion formula I found this
Whilst putting together a T4 template I threw in a simple lambda expression: <#=string.Join(,,
There are lots of similar questions to this, but they all seem to involve

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.