Results 1 to 5 of 5
  1. #1
    Jen0dorf is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453

    Sql syntax error

    Hi

    single table containing two fields notes and notes_2

    I've (with help) merged and deleted most records and am left with 4332 records to update

    these 4332 records: both notes and notes_2 have entries that are not identical but the field in notes_2 is the upto date one.

    So I want to update the notes field with the one from notes_2 without effecting the other 39000 records in the table

    So I created a query that save with no error

    Code:
    UPDATE tblDeceased SET tblDeceased.Notes = [tblDeceased]![notes_2]
    WHERE (((tblDeceased.notes_2)="IsNotNull" And [tblDeceased]![Notes]<>[tblDeceased]![notes_2]));
    I think my logic says update Notes with the value from Notes_2 providing notes_2 contains data and notes and notes_2 are not equal



    I run the query and it tells me 0 records are to be updated yet if I visibly look I can see the records I want to update.

    I've been caught out before with wording of queries (And caused me hours of stress) , is my code wrong?

    thanks

    Ian

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    Is NOTES field is a MEMO type?
    you can't query memo fields.

  3. #3
    Jen0dorf is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453
    Hi

    both fields are long text, I've been experimenting and I suspect my sql is flawed with IsNotNull?

    If I create a test query and run it with ISNOTNULL as criteria is still lists fields that I consider visually to be empty

    Code:
    SELECT tblDeceased.Notes, tblDeceased.notes_2
    FROM tblDeceased
    WHERE (((tblDeceased.notes_2)="Is Not Null"));
    shows 0 entries

    Code:
    SELECT tblDeceased.Notes, tblDeceased.notes_2
    FROM tblDeceased
    WHERE (((tblDeceased.notes_2)=Is Not Null));
    Shows all records regardless of if Notes_2 field is empty or not

    So does Is NOT NULL not mean contains data of some sort?

    thanks

    Ian

  4. #4
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    Try:
    WHERE ((Not (tblDeceased.notes_2) Is Null));

  5. #5
    orange's Avatar
    orange is online now Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,849
    A couple of points:

    ---
    "Is Not Null" -- in quotes would be a literal string.
    Is Not NULL -- is an SQL expression. It is not used with "="

    Reference to SQL and examples

    ----

    Is NOTES field is a MEMO type?
    you can't query memo fields.
    This statement is not true. Perhaps ranman256 meant something else.

    Here is an example of querying a memo field.

    The TXT field of table tbl_Spl_LCL_Std_EstProfileEng is Memo data type. The length of the TXT value is 1595.
    The query selects the last 20 characters of TXT for ESTBLMT_NO 123456197946 but also shows the entire TXT field.

    The table structure is:
    Code:
        table_name                               field_name        field_description        data_type    
        tbl_Spl_LCL_Std_EstProfileEng        RecID             Record Identifier               Long        
        tbl_Spl_LCL_Std_EstProfileEng        Est_Name       Establishment Name          Text        
        tbl_Spl_LCL_Std_EstProfileEng        ESTBLMT_NO  Establishment Number       Text        
        tbl_Spl_LCL_Std_EstProfileEng        TXT_TYP_CD   Text Type Identifier            Text        
        tbl_Spl_LCL_Std_EstProfileEng        TXT                Description text  (memo)    Memo

    Here is the query sql:
    Code:
    SELECT tbl_Spl_LCL_Std_EstProfileEng.ESTBLMT_NO
    , Len([TXT]) AS LENGTH
    , Right([txt],20) AS Last20
    , tbl_Spl_LCL_Std_EstProfileEng.txt
    FROM tbl_Spl_LCL_Std_EstProfileEng
    WHERE
     (((tbl_Spl_LCL_Std_EstProfileEng.ESTBLMT_NO)="123456197946"));
    Attached is a picture(jpg) of the output of the query.
    Attached Thumbnails Attached Thumbnails QueryMemo.jpg  

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

Similar Threads

  1. Replies: 2
    Last Post: 01-04-2016, 09:40 AM
  2. Replies: 11
    Last Post: 05-01-2014, 11:56 AM
  3. Replies: 3
    Last Post: 01-23-2014, 07:49 AM
  4. Replies: 6
    Last Post: 05-30-2012, 12:32 PM
  5. Incomplete Syntax Clause (syntax error)
    By ajetrumpet in forum Programming
    Replies: 4
    Last Post: 09-11-2010, 10:47 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