Solved

Insert Not working, Can you spot why

Posted on 2014-02-19
3
273 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 48

Expert Comment

by:Dale Fye
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

623 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