Solved

Insert Not working, Can you spot why

Posted on 2014-02-19
3
271 Views
Last Modified: 2014-02-19
I just created the following insert statement in my application.  I have many others just like it, except for differnet tables.  It compiles cleanly, I verified that all of the fields have valid data in them.  The numerics have numbers, the dates have dates and the strings have strings.

I verified that the command executes, no errors or warnings are thrown.  However, it doesn't add a new record to the specified table.

Here is the statement:

    CurrentDb.Execute " insert into  tblProperty_PhoneNumbers " & _
                  "( [PropertyID], [BRT], [PhoneNum], [PhoneNum_JustNum], [DialerStatusID], [DateNumberEntered], [DatePhoneStatusUpdated], [DateAdded], [UserAdded] " & _
      "   values(" & passedPropertyID & _
              ", " & passedBRT & _
              ", " & Chr(34) & passedPhoneNum & Chr(34) & _
              ", " & wkJustPhoneNum & _
              ", " & passedCallResultID & _
              ", " & Chr(35) & wkDateAdded & Chr(35) & _
              ", " & Chr(35) & wkDateAdded & Chr(35) & _
              ", " & Chr(35) & wkDateAdded & Chr(35) & _
              ", " & Chr(34) & wkUserAdded & Chr(34) & _
              ")"

Open in new window


I use the chr(35) for # and chr(34) for ".  I do this many places in my app also, including on other insert statements.

Can any one spot an issue?
0
Comment
Question by:mlcktmguy
3 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 250 total points
ID: 39871349
you are missing a closing paren ")" before  "values"


    CurrentDb.Execute " insert into  tblProperty_PhoneNumbers " & _
                  "( [PropertyID], [BRT], [PhoneNum], [PhoneNum_JustNum], [DialerStatusID], [DateNumberEntered], [DatePhoneStatusUpdated], [DateAdded], [UserAdded]) " & _
      "   values(" & passedPropertyID & _
              ", " & passedBRT & _
              ", " & Chr(34) & passedPhoneNum & Chr(34) & _
              ", " & wkJustPhoneNum & _
              ", " & passedCallResultID & _
              ", " & Chr(35) & wkDateAdded & Chr(35) & _
              ", " & Chr(35) & wkDateAdded & Chr(35) & _
              ", " & Chr(35) & wkDateAdded & Chr(35) & _
              ", " & Chr(34) & wkUserAdded & Chr(34) & _
              ")"
0
 
LVL 1

Author Closing Comment

by:mlcktmguy
ID: 39871525
Bingo, thanks
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39871755
You might benefit from my Wrap function:
Public Function Wrap(WrapWhat as Variant, _
                     Optional WrapWith as String = """") as String

    If IsNull(WrapWhat) then WrapWhat = "NULL"

   Wrap = WrapWith _
        & Replace(WrapWhat, WrapWith, WrapWith & WrapWith) & WrapWith

End Function

Open in new window

Then, in your code you would write:

strSQL = "insert into  tblProperty_PhoneNumbers " _
        & "([PropertyID], [BRT], [PhoneNum], [PhoneNum_JustNum], " _
        & "[DialerStatusID], [DateNumberEntered], [DatePhoneStatusUpdated], " _
        & "[DateAdded], [UserAdded]) " _
        & "Values(" & passedPropertyID _
             & ", " & passedBRT _
             & ", " & WRAP(passedPhoneNum) _
             & ", " & wkJustPhoneNum _
             & ", " & passedCallResultID _
             & ", " & Wrap(wkDateAdded, "#") _
             & ", " & Wrap(wkDateAdded, "#") _
             & ", " & Wrap(wkDateAdded, "#") _
             & ", " & Wrap(wkUserAdded) _
             & ")" 
Currentdb.Execute strSQL, dbFailonError

Open in new window

0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question