the command or action setwarnings isn't available now

jydbman

Registered User.
Local time
Today, 14:43
Joined
Nov 23, 2007
Messages
40
I have a access 2002 application with several forms. I open those forms by clicking the continue button one after another by order. Once the next form is open, the previous form will be hidden. If the next form unload, the previous form will be shown. In the last form, there are several buttons to perform some different actions. The following is part of code in the cmd_click sub. Some time, it error out with the error message the command or action setwarnings isn t available now. When I click the debug, it points to DoCmd.SetWarnings False. Sometimes it works without any problem but sometimes it errors out. What's the reason? I searched online and found many similar posts but can not find a straight answer to know what's the real problem and how to resolve the problem.

Thank you very much!

Dim sqlupdate As String

sqlupdate = "update data set "
sqlupdate = sqlupdate & "reference= 1"
sqlupdate = sqlupdate & " where projectno = '" & projectno & "' And "
sqlupdate = sqlupdate & " company = '" & company & "' And "
sqlupdate = sqlupdate & " test = '" & Test & "' And "
sqlupdate = sqlupdate & " extension = '" & extension & "'"
DoCmd.SetWarnings False
DoCmd.RunSQL (sqlupdate)
DoCmd.SetWarnings True
 
hi jyd,

I did some searching on this too, as I was interested in why random errors pop up like this. Obviously this is not a solution, but would you be happy with simply acknowledging the fact that Access is not a perfect piece of software?

I know that sounds useless, but I've had plenty of the same types of problems in the past, really with no explanation, and what I found was that any complaints that came my way because of it were easily resolved by shifting the blame to Microsoft and making them look like the ultimate culprit (which of course they are, for some things that are overlooked).

I know that's not the answer you're looking for, but I thought I would throw that out there just in case you haven't heard anything like it before. :)

Some of the best troubleshooting that I've ever done involved talking about how much Microsoft deploys without double checking. And of course, to my surprise, the problem is usually not asked about again, or for a long time. :)

Again, not perfect of course, but a very strategic way of looking good, when someone else makes you look bad.
 
...and if you use CurrentDB.Execute sqlupdate, dbFailOnError then you do not need to use SetWarnings.
 
...and if you use CurrentDB.Execute sqlupdate, dbFailOnError then you do not need to use SetWarnings.

:) Thank you for that addition! By the way, have you ever had problems with CurrentDB?? I have had a few, but never when a variable was dimmed as DAO.database and set as the current. I've also seen posts on other forums about this problem, but I think it's rare. However, quite useful as a 'preventive' tactic, heaven for bid it ever does come up!
 
hi jyd,

I did some searching on this too, as I was interested in why random errors pop up like this. Obviously this is not a solution, but would you be happy with simply acknowledging the fact that Access is not a perfect piece of software?

I know that sounds useless, but I've had plenty of the same types of problems in the past, really with no explanation, and what I found was that any complaints that came my way because of it were easily resolved by shifting the blame to Microsoft and making them look like the ultimate culprit (which of course they are, for some things that are overlooked).

I know that's not the answer you're looking for, but I thought I would throw that out there just in case you haven't heard anything like it before. :)

Some of the best troubleshooting that I've ever done involved talking about how much Microsoft deploys without double checking. And of course, to my surprise, the problem is usually not asked about again, or for a long time. :)

Again, not perfect of course, but a very strategic way of looking good, when someone else makes you look bad.


You make me lol. :)
Thanks for sharing! That's very true about Microsoft. Oftentimes, it's not very stable and comes up many weird problems and I have no idea what caused those issues. It did make me look bad when I had to demo the program to my boss and had no idea how to fix the issue.
 
...and if you use CurrentDB.Execute sqlupdate, dbFailOnError then you do not need to use SetWarnings.

Thank you so much! It works very well and I don't need to worry about the weird error message! I did not know before that I can use CurrentDB.Execute sqlupdate, dbFailOnError to prevent the warning message. Thanks for the great help!

 

Users who are viewing this thread

Back
Top Bottom