Solved Syntax Error while updating (1 Viewer)

SachAccess

Active member
Local time
Today, 10:42
Joined
Nov 22, 2021
Messages
389
Hi @Pat Hartman thanks for the help. I will fix it now. To be honest, I was not aware that it is in-correct line.
Have a nice day ahead. :)
Did you fix the Me.Dirty = True to = False?
What is the purpose of the If that follows? You are checking Me.Q123 and setting MyComm to two different values. Obviously only the second value remains:(
Why are you storing the same data in multiple tables?
 

SachAccess

Active member
Local time
Today, 10:42
Joined
Nov 22, 2021
Messages
389
Suggest talk to your bosses and clarify, can understand data but cannot see why they would object to object and field names.

The problem is if you have a problem and it is related to spelling or object type and you say you have a problem and give a different spelling - or create typos because you don't copy paste, that just wastes everyone's time because the focus is on that and not the real issue.

The other problem is because you change names - you started with Form_Frm_ABC, then changed to frm_MainForm and then you say things like 'Me.Name = Form 3, this is not Form 1'.
Hi @CJ_London I agree with you. Typos are creating more problems which did not exist in real place.
I did not realize this 'that just wastes everyone's time because the focus is on that and not the real issue.'
My apologies, it is more irritating that the actual problem. Will take care going forward.
Have a nice day ahead. :)
 

SachAccess

Active member
Local time
Today, 10:42
Joined
Nov 22, 2021
Messages
389
Always use the real names for your fields, forms and tables.
Copy and paste the code exactly don't edit it.

We can't spot typo's etc if they are there if it's not the EXACT code you are running.
Hi @Minty I agree. Going forward, I will take care. Have a nice day ahead. :)
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 06:12
Joined
Sep 12, 2006
Messages
15,662
this line

CurrentDb.Execute "Update MyTabe set ShortInfo='" & Me.Q123 & "', QAZ='" & Me.QAZ_ID & "', MyStatus=" & Me.WSX & " Where MyID=" & Form!frm_Second.MyID

The syntax changes according to whether the field being updated is numeric, a string or a date. It there are spaces in your field names you need to include square brackets around the [field name]

As already mentioned, I would include extra spaces. Adding spaces around the equals signs as below may make a difference.

CurrentDb.Execute "Update MyTabe set ShortInfo = '" & Me.Q123 & "', QAZ = '" & Me.QAZ_ID & "', MyStatus = " & Me.WSX & " Where MyID = " & Form!frm_Second.MyID

Why don't you try to create an update query in the design pane, and then view it as SQL. That will show you what the SQL should look like. Try a simpler query first, and build up to more complicated one.

The line I quoted can be error trapped, which may help

Code:
on error goto updatefail
    CurrentDb.Execute "Update MyTabe set ShortInfo='" & Me.Q123 & "', QAZ='" & Me.QAZ_ID & "', MyStatus=" & Me.WSX & " Where MyID=" & Form!frm_Second.MyID, dbfailonerror

exit sub

updatefail:
msgbox "Error with Execute" & vbcrlf & _
  "Error: " & err & "   Desc: " & err.description
 

expat1000

Registered User.
Local time
Yesterday, 22:12
Joined
Apr 6, 2012
Messages
18
SqlDebugPrint
With this add-in you can speed up and improve the display and checking of the generated SQL statement. In the case of action queries, a transaction ensures that no data in the table is changed as a result of the check process. Use in code after installation:
Code:
SqlDebug strSQL

However, one could also use real parameter queries and thus avoid such formatting problems.
Hi - the link for SqlDebugPrint is not working for me.
 

Users who are viewing this thread

Top Bottom