UPDATE query won't work after warning set to false

rickyfong

Registered User.
Local time
Today, 14:38
Joined
Nov 25, 2010
Messages
199
DoCmd.SetWarnings False

Dim stDocName As String

stDocName = "Tupdate1"
DoCmd.OpenQuery stDocName, acNormal, acEdit

DoCmd.SetWarnings Ture

If included the two setwarning statements, the update query won't work but when running without them, the update query worked well. Any idea?? Thanks!!
 
DoCmd.SetWarnings Ture

that should be
DoCmd.SetWarnings True

Parhaps that is causing an error?
 
Yes, there is a spelling mistake over there. And it simply couldn't set warning back to normal. I found out the problem is not due to that. It seems when I run the update query using hard code e.g. "T12345", it works well. But when I use something like the following:
Forms![workingsum].Text168 in the criteria.

The query seems couldn't find the value from the workingsum even though I have use a MSGBOX to display the value is right stored in the TEXT168.

MY idea is to call the update query under a field's after_update sub in a form. And the workingsum form trigged that form to open a list. When user click the relevant field, the update query under that after_update should first refer to the TEXT168 and then do the update action.

When I run the update query individually using a hard code, it worked well. Any further idea?? Thanks a lot!!
 
Last edited:
When running queries from code working with references to forms is pretty iffy.... :(
Instead if you are executing this from within your form, try making something like:

Plus you are trying to OPEN the update query, you cannot open an update query, instead you should use Currentdb.Execute (which will not give you messages in the first place) or Docmd.RUNSQL

Code:
dim strSQL as string
strSQL = "Update.... where somefield = """ & Me.Text168 & """"
Currentdb.execute strsql
 

Users who are viewing this thread

Back
Top Bottom