Results 1 to 4 of 4
  1. #1
    tonyl is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    3

    expression builder


    I'm trying to change a label caption in a report depending the value of a numeric field.
    =IIf([55]=8,[Label176].[Caption]="Spring Term",[Label176].[Caption]="Summer Term")
    [55] is the numeric field.
    I get a type mismatch error. Any ideas?
    Access 2010

  2. #2
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Naming a field with only numeric digits is never a good idea - you never really know when it will confuse Access.

    Where and how are you using that expression? The error might not be in the actual expression, but in how you are using it.

    But try changing the name of [55] to F55 or similar to see if that works.

    John

  3. #3
    tonyl is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    3
    thanks for advice re numeric fields, I will give it a try.
    I'm using the expression in the report On Open and tried On Load.
    Tony

  4. #4
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    I think your problem may be that you are putting your iif expression into the On Open property of your report. You can't do that - the setting can be only [Event Procedure], the name of a macro, or the name of a user-defined function, preceded by an = sign, e.g. =myfunction().

    Which report event you put the code in will depend on where the label is used in the report, i.e. is it the same for the whole report, or does it change for each detail line?

    I also have just noticed that you are not using the iif correctly. The iif function returns one of two values, depending on the condition - but it does not set the values within the parameter list as you have shown. Your code should look like this:

    [Label176].[Caption] = IIf([55]=8,"Spring Term","Summer Term")

    HTH

    John

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

Similar Threads

  1. Expression Builder Problem
    By benthamq in forum Forms
    Replies: 3
    Last Post: 10-07-2011, 01:02 PM
  2. Expression Builder or VB ... Help
    By Adynn in forum Access
    Replies: 0
    Last Post: 06-03-2011, 09:51 AM
  3. Expression builder
    By PJ_d_DJ in forum Access
    Replies: 2
    Last Post: 02-24-2011, 03:38 AM
  4. Expression Builder: If DateValue
    By Rip22 in forum Queries
    Replies: 4
    Last Post: 03-09-2010, 10:51 AM
  5. Expression Builder
    By mistaken_myst in forum Access
    Replies: 2
    Last Post: 05-07-2008, 01:30 PM

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