Solved

update sql server linked table using dao for null fields

Posted on 2016-10-20
3
44 Views
Last Modified: 2016-10-28
access 2010
sql server 2008 r2 - linked tables

I have some code that i'm using to save data to a linked sql server table.
Dim R As DAO.Recordset
Set R = CurrentDb.OpenRecordset("SELECT * FROM [dbo_t_escalation_master] WHERE [PRICING_ESCALATION_ID] =  " & t & " ", dbOpenDynaset, dbSeeChanges)
r.edit
      R![OPPORTUNITY_VALUE] = Nz(Me("OPPORTUNITY_VALUE"), "")
      R![QUOTE_GP] = Replace(Me!QUOTE_GP, "%", "")

etc...


I do ok until , "OPPORTUNITY_VALUE" is null or "quote_gp" if trying to save data.

In sql server tables / access field types
"OPPORTUNITY_VALUE" =  money  / access =  currency
"quote_gp" = int      /   access =  number


These 2 fields will throw an error if they are null or blank ?

when trying to save a record.


Thanks
fordraiders
0
Comment
Question by:fordraiders
3 Comments
 
LVL 36

Accepted Solution

by:
PatHartman earned 400 total points
ID: 41852668
That's because '' is a ZLS (Zero Length STRING) and you can't put a string into a numeric field.

Change to:

r.edit
      R![OPPORTUNITY_VALUE] =  Me("OPPORTUNITY_VALUE")    
      R![QUOTE_GP] = Replace(Me!QUOTE_GP, "%", Null)

etc...

You should also consider changing how you reference form fields.  Using Me.Opportunity_Value and Me.Quote_Gp will give you intellisense and you'll be able to see typos immediately.
0
 
LVL 20

Assisted Solution

by:crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access earned 100 total points
ID: 41852884
additionally,
if Not IsNull(Me!QUOTE_GP) then {assign value}
0
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 41864510
thanks !!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

730 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