Results 1 to 6 of 6
  1. #1
    skurra is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2014
    Posts
    3

    how to Handle NULLS in MsAccess

    Hi,



    I have below table in SQL Server which i have linked to MS Access 2010.

    Create table test
    (
    col1 int not null
    col2 int not null
    )

    Insert into Test values (1,2)
    Insert into Test values (1,'')

    Now when i link the table to access database and open up the table i dont have any issues with that. I tried to copy the test table data from access table and paste it to another access table which is linked to sql server with same schema structure thats when it says "You tried to assign the NULL value to a variable that is not a variant data type"

    Its treating the blanks as NULLS when copy/paste the records from one table in access to another .. how do i fix that ?

    Thanks in Advance

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Sounds like an SQLServer issue. SQLServer does not like Null? What is an empty field in SQLServer?

    Maybe an INSERT SELECT query to add records to the SQLServer table. Use Nz() function to handle possible Null.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    skurra is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2014
    Posts
    3
    Sorry to ask this dumb question , where exactly should i use the NZ() function in access as it is a linked table to SQL Server.. I have read about NULL To zero function but didnt know where exaclty should i use it.. Is it under validation rule ?

    Thanks in advance

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    You said you are doing copy/paste to insert records into SQLServer table.

    Try building a query and do the copy/paste from the query to SQLServer table.

    The query can have an expression using Nz() that will convert Null to whatever you want.

    SELECT Nz(fieldname, 0) AS SomeAliasName FROM tablename;
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    skurra is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2014
    Posts
    3
    Let me explain you in more detail..

    There are two tables created in SQL Server Table1 & Table2 with exact same schema. Both of them are linked to access database .
    One of the table has been populated with data out of which one of the column is mandatory column so they have few blanks in the data in sql server.
    Now when the user open the table from access db they can view the data. Now the users are trying to copy the data from access.table1 and paste it into access.table2 as they wouldnt have access to sql server, that when they are getting the above error as access is treating those blanks as nulls and returning an error

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    If the destination field is required, then that might cause issue, regardless of the nature of table (native Access or linked).

    I think the error is really triggered by SQLServer. If SQLServer is not allowing the Nulls then cannot do copy/paste from raw data. Try it from a query as suggested.

    Why are users working directly with tables anyway?

    Why are there two tables with same data?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Learn MSAccess by playing MSAccess Jeopardy
    By pkstormy in forum Sample Databases
    Replies: 4
    Last Post: 11-17-2016, 07:27 AM
  2. Having problems with Nulls in joins
    By RJLLodigiani in forum Access
    Replies: 7
    Last Post: 08-11-2014, 07:04 AM
  3. Nulls problem, hmm
    By redbull in forum Programming
    Replies: 6
    Last Post: 06-29-2012, 12:16 PM
  4. SUM in regards to nulls
    By detlion1643 in forum Access
    Replies: 5
    Last Post: 02-03-2010, 08:50 AM
  5. GetRows - Invalid Use of Nulls
    By Wannabe_Pro in forum Programming
    Replies: 3
    Last Post: 07-22-2009, 07:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums