RE: Insert Code Not Working
- From: Klatuu <Klatuu@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 15 May 2008 13:38:15 -0700
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) & ") "
- References:
- Insert Code Not Working
- From: KKash
- Insert Code Not Working
- Prev by Date: RE: Update table with unbound combo box with sql string
- Next by Date: RE: Update table with unbound combo box with sql string
- Previous by thread: Re: Insert Code Not Working
- Index(es):
Relevant Pages
|