Page 2 of 2 FirstFirst 12
Results 16 to 18 of 18
  1. #16
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    Thank you all,

    This seems to work like a charm...\
    Code:
    Private Sub CurrentBalance_AfterUpdate()
    Dim strsql As String
    Dim db As DAO.Database
    Set db = CurrentDb
    Me.CurrentBalanceDate = Now()
    
    
    If Not Me.NewRecord Then
        Select Case Me.cboAccountTypeID
    
    
        Case 1, 2, 4 'Asset, Equity or Income
             strsql = "UPDATE tblAccountLedger SET Credit = " & Me.CurrentBalance & " WHERE AccountID=" & Me.AccountID
        Case Else 'Or Case In (3,5,6) Expense,Liability LT and ST
             strsql = "UPDATE tblAccountLedger SET Debit = " & Me.CurrentBalance & " WHERE AccountID=" & Me.AccountID
        End Select
        db.Execute strsql, dbFailOnError
    End If
    
    
    Set db = Nothing
    
    
    End Sub
    Thank you

  2. #17
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    I would not use case else for the other 3?
    What happens if you get another type which is a credit?
    Use the else to indicate not catered for.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #18
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    Thaak you Welshgasman
    That is a great point
    Thank you

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 8
    Last Post: 01-10-2021, 04:58 AM
  2. UPDATE Query Too Few Parameters
    By Monterey_Manzer in forum Queries
    Replies: 2
    Last Post: 09-05-2013, 02:09 PM
  3. Update more queries with the same parameters
    By Christian1977 in forum Programming
    Replies: 4
    Last Post: 06-28-2013, 02:57 AM
  4. Passage of parameters - Form Update
    By altotoe in forum Programming
    Replies: 2
    Last Post: 04-19-2013, 04:19 AM
  5. Too Few Parameters - UPDATE SQL
    By jgelpi16 in forum Programming
    Replies: 3
    Last Post: 09-20-2010, 10:11 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