Results 1 to 3 of 3
  1. #1
    peter_lawton is offline Novice
    Windows XP Access 2002
    Join Date
    Sep 2009
    Location
    London
    Posts
    29

    Using an expression to add a record based on a field containing any text

    In Access 2002 I am attempting to add text to Field 2 if Field 1 contains any text at all using a query expression.



    I have tried innumerable combinations of IIf, Is Not Null, Like using wildcards etc. For example IIf([Composer] is not null), "CA" (Suggested on an MS site) however I can't seem to find the right expression. I know this should be simple so please excuse my dumbness today.

    Help greatly appreciated

    Peter

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    I read through your post a few times trying to figure out whether you're trying to get what you need using a query or using VBA code in a Form . . .
    Can you post some more details and perhaps the entire SQL?

    Your IIF statement does not appear to be posted in its entirety - and it also appears to be syntactically incorrect?
    It should read something like this:
    Code:
    IIf([Composer] Is Not Null, "CA", "Value_If_False")

  3. #3
    peter_lawton is offline Novice
    Windows XP Access 2002
    Join Date
    Sep 2009
    Location
    London
    Posts
    29
    I'm just trying to Using your expression

    Composer1 Composer1_Capacity Composer2 Composer2_Capacity

    Apple CA Carrot
    Orange CA
    Cherry CA Swede
    Mango CA
    Banana CA Cabbage

    SELECT Composer.Composer1, Composer.Composer1_Capacity, Composer.Composer2, Composer.Composer2_Capacity
    FROM Composer
    WHERE (((Composer.Composer2_Capacity)=IIf([Composer2] Is Not Null,"CA","Value_If_False")));

    Also tried IIf([Composer2] Like "*" ,"CA")

    Same Result

    but then I had a thought

    SELECT Composer.Composer1, Composer.Composer1_Capacity, Composer.Composer2, IIf([Composer2] Like "*","CA") AS Composer2_Capacity
    FROM Composer
    GROUP BY Composer.Composer1, Composer.Composer1_Capacity, Composer.Composer2;

    Solved

    You got me thinking thanks

    Peter

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

Similar Threads

  1. Replies: 1
    Last Post: 01-29-2012, 01:06 PM
  2. Replies: 1
    Last Post: 08-04-2011, 04:17 PM
  3. Selecting a corresponding table field based on text field.
    By michaeljohnh in forum Programming
    Replies: 5
    Last Post: 10-08-2010, 10:33 AM
  4. Populating attachment field based on text box
    By justinwright in forum Forms
    Replies: 16
    Last Post: 09-22-2010, 08:38 AM
  5. Replies: 2
    Last Post: 05-05-2010, 02:52 PM

Tags for this Thread

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