Docmd statement

Prayder

Registered User.
Local time
Today, 11:45
Joined
Mar 20, 2013
Messages
303
What exactly does
Code:
docmd.setwarnings false

do exactly? And why would you put this in a module
 
What would be the purpose of using docmd.runsql statement then at all?
 
That's a completely different function, so it has a completely different purpose. Its purpose is to execute SQL.

It sounds like you have a situation in developing your database that you are having difficulty working through. How about you explain your situation, where you are stuck and we can offer advice.
 
Actually,

I am just trying to understand:
Code:
Private Sub cmbProject_AfterUpdate()
    Me.RequisitionSubmitDetails.Form.Refresh 'save data back to database
    
    'change project id for all lines in this requisition
    DoCmd.SetWarnings False
    DoCmd.RunSQL ("UPDATE RequisitionDetails SET ProjectId = " & _
        Me.cmbProject & " WHERE RequisitionNo = " & Me.ReqID)
    DoCmd.SetWarnings True
        
    Me.RequisitionSubmitDetails.Form.Refresh 'push changes back to screen
    
End Sub

This code and what it actually does. We converted from Lotus Notes to Outlook and so I am working on changing over all the code in the databases to reflect that. But since I dont understand vb coding I am taking it one step at a time.
 
About a year ago I was moved into a position of administering these access databases and I didnt know anything about them. All the db's were already in place so it wasnt like learning from scratch. I have learned access for the most part but havent had to use much coding on the backside until now.
 
That function will still do what it is suppose to do if you take out the DoCmd.SetWarnings statements, it will just be more annoying to the user.

On a fresh install of Access there's a checkbox setting that says something like 'Confirm Database Updates' which is turned on by default. So whenever an action query is run (APPEND, UPDATE, MAKE TABLE) it displays a prompt to confirm that query before running it ('Access is going to Append 4 Rows. Do you want to continue this action?').

DoCmd.SetWarnings False will override that setting so the user doesn't have to confirm the action query, it just runs. Then when they were done, the guy who wrote that code, turned the confirmations back on with DoCmd.SetWarnings True

Like I said, removing the .SetWarning statements will not have any effect on the code other than making it more annoying to run. Comment them out, then run it to see what I mean--you won't break anything. Then uncomment them to bring them back.
 

Users who are viewing this thread

Back
Top Bottom