Results 1 to 4 of 4
  1. #1
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    754

    MsgBox question on Updates and such...

    Hi all,
    I have just a quick question on a message box for different types of strsql and Execute code that are called on, they run
    and nothings that says "Upate Sucessful" or anythiing?
    Do I add just a regular message box to fire after update complete or is their something else?
    Just asking as I dont really know for sure


    Code:
    Private Sub OpenBalanceUpdate()
    Dim strsql As String
    Dim db As DAO.Database
    Set db = CurrentDb
    
    
    Me.OpenBalanceDate = Now()
    
    
    If Not Me.NewRecord Then
        Select Case Me.cboAccountTypeID
    
    
        Case 1, 2, 4 'Asset, Equity or Income
             strsql = "UPDATE tblAccountLedger SET Credit = " & Me.OpeningBalance & " WHERE AccountID=" & Me.AccountID
        Case Else 'Or Case In (3,5,6) Expense,Liability LT and ST
             strsql = "UPDATE tblAccountLedger SET Debit = " & Me.OpeningBalance & " WHERE AccountID=" & Me.AccountID
        End Select
        db.Execute strsql, dbFailOnError
    End If
    
    
    Set db = Nothing
    End Sub
    Thanks
    Dave

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,820
    Because of dbFailOnError parameter, system message would popup if the action failed due to syntax or data type mismatch error. Could build an error handler in the procedure to trap that error and provide a custom message and if there is no error, issue a "Successful" MsgBox.

    However, if WHERE criteria is not valid, the UPDATE could still execute without error but not actually update anything. Review https://www.techonthenet.com/access/...dsaffected.php
    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
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    As part of the message box that you add, the number of records updated can be included using the RecordsAffected database property. See MS Access 2003: Determine number of records affected by an Execute command (techonthenet.com)
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  4. #4
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    754
    thanks all,
    Have a great new year
    I will review content and go from there
    Best wishes
    Dave

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

Similar Threads

  1. Question on FE updates
    By MadTom in forum Database Design
    Replies: 3
    Last Post: 11-18-2019, 09:55 PM
  2. Replies: 1
    Last Post: 08-10-2017, 09:13 AM
  3. vba MsgBox for some but not all
    By BusDriver3 in forum Macros
    Replies: 18
    Last Post: 12-15-2016, 09:33 PM
  4. Easy msgbox question
    By Madmax2 in forum Programming
    Replies: 3
    Last Post: 07-23-2014, 09:52 AM
  5. Yes No msgbox
    By imintrouble in forum Access
    Replies: 3
    Last Post: 10-14-2011, 02:24 PM

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