Results 1 to 3 of 3
  1. #1
    D4WNO is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    10

    Unable to edit data in Union table

    Hi everyone,

    I'll try to explain the best I can as I didn't write this SQL code myself, the person who did is no longer here.

    I have a Union query that is linked into about 10 different excel spreadsheets on our drive and it pulls back only 3 columns of data (Document Number, Date Registered and Date Implemented). I then have another report which refers to the results of this query and does its own thing from thereon.


    Here is a sample of the SQL:



    SELECT CINT(RIGHT(RT_01000.[Rev-Trac Number],5)) as [Document Number], RT_01000.[CC_RT Issue Date] as [Date Registered], RT_01000.[Actual Delivery Date] as [Date Implemented] FROM RT_01000;

    UNION SELECT CINT(RIGHT(CC_RT_01000.[Rev-Trac Number],5)) as [Document Number], CC_RT_01000.[CC_RT Issue Date] as [Date Registered], CC_RT_01000.[Actual Delivery Date] as [Date Implemented] FROM CC_RT_01000;


    My Issue:

    As it is above, the query will run, but we end up with duplicate numbers in the "Document Number". It only brings back the final 5 digits from each of these files and ignores the differenciating part of the number, the "CC_RT_" or the "RT_". This causes huge issues in the file which then goes onto use these results afterwards.

    My Plan: (failed)

    I thought I could simply update the "5" to an "11" to catch anything named "RT_00001" and also "CC_RT_00001" serperately so I can clearly see which is which without any duplicates. However, I recieve the below error when doing so:

    "Data type mismatch in criteria expression".

    Please help, I've been playing with this for hours and unfortunately many many reports reply on these results being correct. It is also not possible to change the names of the RT and CC_RT files that it links into.

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    The CINT function converts the value to an Integer (numeric). If you are including the text portion (i.e. "RT", "CC_RT_"), those aren't valid numeric entries, which is why you are getting the Data Type mismatch error.

    Try removing the CINT function from each part, i.e.
    Code:
    SELECT RIGHT(RT_01000.[Rev-Trac Number],11) as [Document Number], RT_01000.[CC_RT Issue Date] as [Date Registered], RT_01000.[Actual Delivery Date] as [Date Implemented] FROM RT_01000;
    
    UNION SELECT RIGHT(CC_RT_01000.[Rev-Trac Number],11) as [Document Number], CC_RT_01000.[CC_RT Issue Date] as [Date Registered], CC_RT_01000.[Actual Delivery Date] as [Date Implemented] FROM CC_RT_01000;

  3. #3
    D4WNO is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    10
    Thank you very much, that worked

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

Similar Threads

  1. Unable to edit Data in Query
    By undee69 in forum Forms
    Replies: 4
    Last Post: 06-10-2012, 10:43 PM
  2. Prevent edit or delete data or records from a table
    By mosquito_admin in forum Security
    Replies: 1
    Last Post: 03-01-2012, 06:02 PM
  3. Replies: 2
    Last Post: 02-13-2012, 02:41 PM
  4. Replies: 12
    Last Post: 06-16-2011, 01:35 PM
  5. Replies: 0
    Last Post: 03-14-2011, 08:38 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