473,399 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

docmd.setwarnings false isn't working...

21
Good Afternoon

I have an option grou[ and on the after update i would like to provide the user with a msgbox, and then action

placed my docmd.setwarnings false everywhere, but i still get my "record has been deleted".

Is i possilbe to please assist in where i am going wrong

Private Sub RecOffLet_AfterUpdate()
On Error GoTo Err_Handler

DoCmd.SetWarnings False

Dim nResponse As Integer

If Me.RecOffLet = -1 Then

nResponse = MsgBox("Would You Like to Move The Candiate to The Eployment Table", vbYesNo + vbQuestion, "Question")

If nResponse = vbYes Then


DoCmd.RunSQL ("INSERT INTO tblEmpInfo SELECT * FROM TblOffer " & _
"Where ID = Forms!frmOffer!ID;")


DoCmd.RunSQL ("DELETE * FROM TblOffer " & _
"Where ID = Forms!frmOffer!ID;")

DoCmd.SetWarnings False



Forms!FrmOffer.Requery

DoCmd.SetWarnings False

'End If
DoCmd.SetWarnings False


Exit_RecOffLet_AfterUpdate:
Exit Sub

Err_Handler:
MsgBox Err.Description
Resume Exit_RecOffLet_AfterUpdate
End If
'End If
End If
Jul 18 '08 #1
1 3032
Stewart Ross
2,545 Expert Mod 2GB
Hi. There is no need for the profusion of DoCmd SetWarnings False. Once is enough - and you should turn them on again by placing DoCmd SetWarnings True after the last action statement has run.

You are confusing the warnings - which are the user messages asking for confirmation before commitment of action queries such as insert or delete - and what happens when you delete the current record showing on a form. If SetWarnings False was not functioning you would be asked for confirmation of your Insert and your Delete.

This is nothing to do with what happens if you delete through code (or by the actions of another user) the current record displayed on your user form. As that record no longer exists, on refresh Access has to let you know that it has been deleted. This is not a warning message as such - its an indication that the record it was displaying no longer exists, and you can't fault Access for letting you know!

Problem is that you may not have thought through what you want to show your user in these circumstances; do you go back to the first record, or show the next one, or what? If you want to show the record you have just deleted, you need to rethink the deletion part altogether.

-Stewart

ps you need to sort out your IF... END IF structure. The end if's lie outside of the main body of the SUB for some reason and seem to encompass your error handler, which is normally at the very end of the code on its own.
Jul 19 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: deko | last post by:
This code is behind a button that exports the contents of a query ("qryXL_Tx") to an Excel spreadsheet. It works fine the first time, but will not run a second time. When I go to look at my...
3
by: jj | last post by:
I've got a form button that fires off 3 queries but if the first query returns an error, I don't want the other two queries to happen. Example: first query runs an insert from a linked table but...
0
by: Andy | last post by:
Hello, I am running an sql statement that INSERTS INTO a table. If I run the query using docmd.runSQL, it works fine - new records are added to the table and duplicate records are disregared (...
13
by: Robert McEuen | last post by:
This is probably really simple, but I can't find a thread that addresses it. Is there any way to evaluate in code whether the current state of the SetWarnings command is set to True or False? I...
8
by: RC | last post by:
In my Access 2002 form, I have a combo box and on the AfterUpdate event I use DoCmd.RunSQL ("UPDATE .... to update records in a table. When it starts to run I get a message "You are about to...
2
by: misscrf | last post by:
I have the following code: Private Sub cmbNYAdmit_NotInList(NewData As String, Response As Integer) On Error GoTo Err_cmbNYAdmit_NotInList Dim Msg, Style, Title Msg = "Please choose Yes, No...
10
by: Dean | last post by:
My client has a db I am working that uses temp tables. During an update procedure, I had the code If fTableExists(tempTblName) = True Then DoCmd.DeleteObject acTable, tempTblName Then I thought...
6
by: RZ15 | last post by:
Hi, I frequently have code in my forms that will turn warnings off, run make table queries, then turn warnings back on using the following code: DoCmd.SetWarnings WarningsOff DoCmd.OpenQuery...
4
by: gazza10001 | last post by:
Hi i hope you can help my company uses access and has modified for its needs usually what happens is you serach for the invoice by its number and then it brings all the information up such as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.