Forum Discussion

John_Bloggsgasgas's avatar
John_Bloggsgasgas
Copper Contributor
Aug 27, 2021
Solved

Runtime Access Options

I don't wont to receive notifications from Sql queries, bat I can't  use the appropriate options to exclude them
  • isladogs's avatar
    isladogs
    Aug 28, 2021

    John_Bloggsgasgas 

    In my experience most users find the warnings irritating

    Personally, I wouldn't give users the option but its your database and can be done if you think its really worth the effort,.

    As users have no means if accessing Access options in runtime, you could consider this as a workround

     

    1. Have a table tblUsers to include these fields:

    UserName - text (based on Windows network login or an application login form

    ShowWarnings - yes/no (boolean) - set default value as false 

    2. Have a settings form linked to that table where users tick a checkbox if they want to see warnings throughout your application

    3. Create a public function GetUserWarningsState to recall that value. Something like this would work (or you can use tempvars)

    Public Function GetUserWarningState() As Boolean
    GetUserWarningState = DLookup("ShowWarnings", "tblUsers", "UserName = '" & Environ("USerName") & "'")
    End Function

    4. Finally each time you run an action SQL statement, modify the code as follows:

    'show warnings only if user has specified their use
    If GetUserWarningsState = False Then DoCmd.SetWarnings False
    DoCmd.RunSQL "Your SQL string here"
    DoCmd.SetWarnings True 'always set/reset warnings true afterwards