UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Table Not Updating, Access 2010    
 
   
SemiAuto40
post Dec 7 2017, 04:17 PM
Post#1



Posts: 457
Joined: 3-April 12
From: L.A. (lower Alabama)


I am having the most aggravating time calling my LogChange in its own module from another form after changes made pullhair.gif
With this code I get a runtime error 3134. I have tried with some success to open a recordset and .addnew - but even that won't work every time.
Anyone? Please?

CODE
Public Sub LogChange(TimeStamp As Date, Old_Classification_ID As String, OldSequential As String, OldRev As Integer, New_Classification_ID As String, NewSequential As String, NewRev As Integer, Activity As String)
        
  Dim strSQL as string

       strSQL = "INSERT INTO tbl_ChangeLog (TimeStamp, UserName, Old_Classification_ID, OldSequential, OldRev, New_Classification_ID, NewSequential, NewRev, Activity ) " & _
                    "VALUES (" & "#" & TimeStamp & "#," & "'" & MyUserName & "'," & "'" & Old_Classification_ID & "'," & "'" & OldSequential & "'," & OldRev & "," & _
                    "'" & New_Classification_ID & "'," & "'" & NewSequential & "'," & NewRev & "," & "'" & Activity & "'" & ");"

            DoCmd.SetWarnings False
            DoCmd.RunSQL strSQL
            DoCmd.SetWarnings True
Go to the top of the page
 
SemiAuto40
post Dec 7 2017, 04:27 PM
Post#2



Posts: 457
Joined: 3-April 12
From: L.A. (lower Alabama)


OK. Never mind. Once I added brackets to the terms in the INSERT INTO code it now works. Hopefully that was the problem! Thinking I did not need brackets if terms did not have any blank spaces.
Go to the top of the page
 
GroverParkGeorge
post Dec 7 2017, 04:29 PM
Post#3


UA Admin
Posts: 31,191
Joined: 20-June 02
From: Newcastle, WA


The best way I know to figure out this kind of problem is to put Debug.Print strSQL into the code and inspect the actual string created by your concatenation using the immediate window. You can copy it from there and try it in a query to see what error(s) are raised.


--------------------
Go to the top of the page
 
GroverParkGeorge
post Dec 7 2017, 04:32 PM
Post#4


UA Admin
Posts: 31,191
Joined: 20-June 02
From: Newcastle, WA


It's likely that one or more of the field names you've picked are reserved words in Access which either should NOT be used for field names, or which must be enclosed in brackets [] in order for Access to recognize them as field names.

Check out this list. and this support document.

I'm thinking TimeStamp would be the guilty one here.

This post has been edited by GroverParkGeorge: Dec 7 2017, 04:33 PM

--------------------
Go to the top of the page
 
SemiAuto40
post Dec 7 2017, 04:35 PM
Post#5



Posts: 457
Joined: 3-April 12
From: L.A. (lower Alabama)


I use debug.print. The strSQL output all looked fine, quotes on strings, no quotes on numbers. It all just looked like it had to have worked... yet didn't. Doing runSQL must require the brackets on this operation.
Go to the top of the page
 
SemiAuto40
post Dec 7 2017, 04:36 PM
Post#6



Posts: 457
Joined: 3-April 12
From: L.A. (lower Alabama)


Thank you for the list link! My 'TimeStamp' is a reserved word actually.

Thanks!
Go to the top of the page
 
GroverParkGeorge
post Dec 7 2017, 06:25 PM
Post#7


UA Admin
Posts: 31,191
Joined: 20-June 02
From: Newcastle, WA


The naming thing can be pretty insidious.

Congratulations on solving the mystery.

Continued success with your project.

--------------------
Go to the top of the page
 
John Vinson
post Dec 8 2017, 08:36 PM
Post#8


UtterAccess VIP
Posts: 4,142
Joined: 6-January 07
From: Parma, Idaho, US


It NEVER hurts to use [square brackets] even if they're not needed. They even help readability once you get used to them - if it's in brackets you know it's the name of an Access object (field, control, form, prompt, or whatever).

--------------------
John W. Vinson
Wysard of Information
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    10th December 2017 - 11:12 PM