RE: Insert Code Not Working

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



There are some syntax issues and as Graham said, the reason you don't see an
error is because you did not use the dbFailOnError option. The Execute
method does not go through the Access User Interface. It goes directly to
Jet. That is why it is faster and doesn't trigger warning messages, but that
also means is doesn't trhow an error unless you use the option. Here is how
your code should be, assuming all four fields are text fields:

Dim strSQL As String

strSql = "INSERT INTO tblSavedMTNs(MTN, AccountNo, GroupID, " & _
"AccountName)" & "VALUES (""" & txtMTN & """, """ & _
AccountNo & """, """ & GroupID & """, """ & tName & """);"
CurrentdbExecute strSQL, deFailOnError

You can execute it straight from the Execute without first putting it in a
string, but first putting it in a string ensures you have the syntax correct
as far as formatting is concerned. That does not mean the syntax is valid
for Jet, it just means it is a complete string that can be sent to Jet.

--
Dave Hargis, Microsoft Access MVP


"KKash" wrote:

The code listed below is the "click" event on an "update" button." When I
click on the button in my form, it doesn't update my table. However, it
doesn't give me an error message!! HELP!!! Why won't it update?

CurrentDb.Execute "INSERT INTO tblSavedMTNs(MTN, AccountNo, GroupID,
AccountName)" & _
"VALUES (" & Chr$(34) & txtMTN & Chr$(34) & ", " & _
Chr$(34) & AccountNo & Chr$(34) & ", " & _
Chr$(34) & GroupID & Chr$(34) & ", " & _
Chr$(34) & AccountName & Chr$(34) & ") "
.



Relevant Pages

  • hi
    ... I'm pretty sure your syntax is correct. ... The point I was making was that you need to check the string you are building that forms the 2nd argument to the LOOKUPCUBE function. ... > Actually i had 3 dim, and one measure.I want to populate ... > execute that string as part of a normal query against the ...
    (microsoft.public.sqlserver.olap)
  • Re: Make-Table Destination Table Name
    ... Not by syntax, but you can make a string that is a valid SQL statement, and ... execute that string. ...
    (microsoft.public.access.queries)
  • RE: SQL stored procedure executing twice
    ... I wasn't aware that DLookupwould execute the "domain" more than once. ... caused the stored procedure to execute twice. ... Dim stDocName As String ... My pass-thru query properties ...
    (microsoft.public.access.modulesdaovba)
  • Re: inconsistent behavior of >FLOAT
    ... If the string represents a valid floating-point number in the syntax ... if the string does not match the syntax given then false ... ">FLOAT enables programs to read floating-point data in legible ASCII format. ...
    (comp.lang.forth)
  • Re: Waveform Mini-Language
    ... The syntax might seem strange at first, ... Got any ideas for how to make a "go" command ... How about "Frequency 500 Hz Voltage 20 Volts Set"? ... Frequency would error check and execute it. ...
    (comp.arch.embedded)