Access Update query not running in VBA but runs manually

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ramedju
    New Member
    • Mar 2017
    • 3

    Access Update query not running in VBA but runs manually

    This part of code executes after the user logs in in the system in Access.
    Code:
    Option Compare Database
    Option Explicit
    
    Function updateShftDate()
    
    On Error GoTo Macro6_Err
    DoCmd.SetWarnings False
    DoCmd.OpenQuery "qryShiftDate", acViewNormal, acEdit
    
    Macro6_Exit:
    Exit Function
    
    Macro6_Err:
    MsgBox Error$
    Resume Macro6_Exit
    DoCmd.SetWarnings False
    
    End Function
    I've also tried replacing the
    Code:
    DoCmd.OpenQuery
    with
    Code:
    currentDb.Execute
    but is not working either. When I tried to set the
    Code:
    DoCMd.SetWarning
    to TRUE, it pops-up the Warning message saying
    Code:
    You are about to run an update query that will modify your data in your table
    This does not work when called in Access VBA. But this runs when the query is manually ran.
Working...