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

  • SEARCH
  • Home
  • 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 3976920
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:51:44+00:00 2026-05-20T04:51:44+00:00

When a user updates the status of an individual case, that change needs to

  • 0

When a user updates the status of an individual case, that change needs to be stamped across all cases under the account number. Within the VB, I am trying to use the following SQL to update the table with the information the user has put into the form.

DoCmd.RunSQL "UPDATE [Main Details] " & _

"SET [Main Details].[Status] = '" & Status & "' " & _

"AND [Main Details].[On Hold] = '" & On Hold & "' " & _

"WHERE   [Main Details].[Account] = '" & Account & "';"

However, I am getting a compilation error, and I suspect it is something to do with “On Hold”. How can I correct this? Any help with this will be greatly appreciated.

For context, I am looking at a combo box called “ReportSelection” on a form called “Main Details”. Within the “After Update” event procedure, there is the following code:

Private Sub
 ReportSelection_AfterUpdate()

     If ReportSelection = "Enforcement Letter" Or ReportSelection = "Fees
 Letter" Or ReportSelection = "Follow
 On Letter" Or ReportSelection =
 "Reminder Letter BO" Or
 ReportSelection = "Reminder Letter CR"
 Or ReportSelection = "Reminder Letter
 CT" Or ReportSelection = "Reminder
 Letter NNDR" Or ReportSelection =
 "Reminder Letter RTD" Or
 ReportSelection = "Reminder Letter SD"
 Then
                 CmbStatus = "HOLD Until"
                 [On Hold] = Date + 5
             End If

     DoCmd.RunSQL "UPDATE [Main Details] " & _
       "SET [Main Details].[Status] = '" & Status & "' " & _
       "AND [Main Details].[On Hold] = '" & On Hold & "' " & _
       "WHERE   [Main Details].[Account] = '" & Account &
 "';"

     DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
 acMenuVer70

     Select Case Me!ReportSelection

     Case "Write Email"

         DoCmd.OpenForm "CaseEmail", acNormal, , , acFormEdit,
 acWindowNormal

         Exit Sub

     Case "Arrangement Letter"

         Set dbs = CurrentDb

        DoCmd.RunSQL "SELECT * FROM [Arrangements] " & _
             "WHERE [Client]  = '" & Me!Client & "' " & _
             "AND   [Account] = '" & Me!Account & "' " & _
             "AND   [Status]  = 'Made';"

         Set rst = dbs.OpenRecordset(SQL)

         On Error GoTo ArrangementNotFound

         rst.MoveFirst

         ' rst!PaymentCode

         rst.Close
         Set dbs = Nothing

         GoTo RunReport
          ArrangementNotFound:

         rst.Close
         Set dbs = Nothing

         MsgBox "No arrangement has been made for this account"

         Exit Sub

     Case "Reminder Letter", _
         "Reminder Letter BO", _
         "Reminder Letter CR", _
         "Reminder Letter CT", _
         "Reminder Letter NNDR", _
         "Reminder Letter RTD", _
         "Reminder Letter SD", _
         "Enforcement Letter", "Commital Letter"

         If [Status] = "HOLD" Then
             MsgBox "Order is on HOLD", vbExclamation
             Exit Sub
         End If

         If Me![Bailiff Name] <> "" Then
             MsgBox "Order is with " & Me![Bailiff Name], vbExclamation
             Exit Sub
         End If

         If [First Letter] <> 0 Then
             GoTo RunReport
         Else
             MsgBox "Order has not yet been 1st Noticed", vbExclamation
             Exit Sub
         End If

     End Select
      RunReport:

     Select Case Me!ReportSelection

     Case "Details - Account", "Nulla Bona - All Cases", "Arrangement
 Letter"

         WhereCondition = "[Client]='" & Me!Client & "' AND [Account]='" &
 Me!Account & "'"

     Case Else

         WhereCondition = "[Reference]=" & Forms![Main
 Details]!Reference

     End Select

     On Error GoTo InvalidReport

     DoCmd.OpenReport Me![ReportSelection], acViewPreview, ,
 WhereCondition, acWindowNormal

     Select Case Me!ReportSelection

     Case "Council Tax Seizure"

         '*** DO NOTHING ***

     Case "Details"

         If Me!Return Then

             Sleep 1000

             SendKeys "%(fp)v{ENTER}Z:\Returns\" & Me!Client
 & "\" & Trim(Me!Account) & "_" &
 Trim(Me!Summons) & ".pdf{ENTER}", True

             Sleep 500

             DoCmd.Close acReport, Me!ReportSelection, acSaveNo

         End If

     Case "Details - Account"

         If Me!Return Then

             Sleep 1000

             SendKeys "%(fp)v{ENTER}Z:\Returns\" & Me!Client
 & "\" & Trim(Me!Account) &
 ".pdf{ENTER}", True

             Sleep 500

             DoCmd.Close acReport, Me!ReportSelection, acSaveNo

         End If

     Case "Nulla Bona"

         If Me!Return Then

             Sleep 1000

             SendKeys "%(fp)v{ENTER}Z:\Returns\" & Me!Client
 & "\" & Trim(Me!Account) & "_" &
 Trim(Me!Summons) & "NB.pdf{ENTER}",
 True

             Sleep 500

             DoCmd.Close acReport, Me!ReportSelection, acSaveNo

         End If

         DoCmd.OpenReport "Details", acViewPreview, , "[Reference]=" &
 Forms![Main Details]!Reference,
 acWindowNormal

         If Me!Return Then

             Sleep 1000

             SendKeys "%(fp)v{ENTER}Z:\Returns\" & Me!Client
 & "\" & Trim(Me!Account) & "_" &
 Trim(Me!Summons) & ".pdf{ENTER}", True

             Sleep 500

             DoCmd.Close acReport, "Details", acSaveNo

         End If

     Case "Nulla Bona - All Cases"

         If Me!Return Then

             Sleep 1000

             SendKeys "%(fp)v{ENTER}Z:\Returns\" & Me!Client
 & "\" & Trim(Me!Account) &
 "NB.pdf{ENTER}", True

             Sleep 500

             DoCmd.Close acReport, Me!ReportSelection, acSaveNo

         End If

         DoCmd.OpenReport "Details - Account", acViewPreview, ,
 "[Client]='" & Me!Client & "' AND
 [Account]='" & Me!Account & "'",
 acWindowNormal

         If Me!Return Then

             Sleep 1000

             SendKeys "%(fp)v{ENTER}Z:\Returns\" & Me!Client
 & "\" & Trim(Me!Account) &
 ".pdf{ENTER}", True

             Sleep 500

             DoCmd.Close acReport, "Details - Account", acSaveNo

         End If

     Case Else

         '------------------------------------------+
         ' STAMP EACH CASE WITH TYPE OF LETTER SENT |
         '------------------------------------------+

         Set con = Application.CurrentProject.Connection

         SQL = "INSERT INTO [Free Type] ( Reference, [Text], Username ) " & _
             "SELECT DISTINCTROW Reference, '" & _
             ReportSelection & " Sent', '" & _
             [Forms]![Current User]![Initials] & "' " & _
             "FROM [Main Details] " & _
             "WHERE Client  = '" & [Forms]![Main Details]![Client] & "' "
 & _
             "AND   Account = '" & [Forms]![Main Details]![Account] &
 "';"

         con.Execute SQL

     End Select

     Exit Sub

 InvalidReport:

     MsgBox "This report is currently unavailable, please try again later."

End Sub

Also, it is worth mentioning that a similar piece of code works for a different combo box, without any kind of relevant declarations in the code.

Apologies for not providing much context before, this is my first foray into VB, SQL and Access.

  • 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-05-20T04:51:45+00:00Added an answer on May 20, 2026 at 4:51 am

    The short answer is: Don’t use spaces in your field or table names.

    It is clear that you are in dire need of an improved understanding of Access fundamentals, but for now I’ll just concentrate on getting you over your current hurdle.

    When you add a field to a form in access with spaces in the field name, Access silently replaces the spaces with underscores. So the following code should work with your database as it is currently designed:

    CurrentDb.Execute "UPDATE [Main Details] " & _
    "SET [Main Details].[Status] = '" & Status & "' " & _
    ", [Main Details].[On Hold] = '" & On_Hold & "' " & _
    "WHERE   [Main Details].[Account] = '" & Account & "';", dbFailOnError
    

    I also changed the AND to a comma in your UPDATE statement, replaced DoCmd.RunSQL with CurrentDb.Execute with the dbFailOnError option so that your query won’t throw up dialog boxes or fail silently (if you turn off the warnings, as most people do with DoCmd.RunSQL).

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

Sidebar

Related Questions

I'm using Twitter's OAuth API to updates a user's twitter account (twitter status update)
I am building a desktop application that needs to update current user's status frequently.
I have a model function that updates a user in my CodeIgniter application: //
I have a Win32 C++ program that validates user input and updates the UI
I'm trying to make a progress bar that updates the user on the progress
Hi Im writing an app that allows users to post status updates from within
I develop a web application that is getting user updates from a web service
I am trying to get user status updates using the graph API. These are
I'm developing a web application that will enable users to post short status updates
I'd like to create a reusable Django app that handles status updates of the

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.