mlcktmguy
asked on
Insert Not working, Can you spot why
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:
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?
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) & _
")"
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
ASKER