Results 1 to 4 of 4
  1. #1
    ack9f is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2010
    Posts
    2

    Update Query too long


    Hi, I have an if/then statement that is way too long but i can not figure out how to solve the problem another way. This is what I am trying to do:
    I have a column with days of the month. There are also some day codes that need to be converted to actual days of the month so
    1-31 should stay the same
    41 should change to "05"
    43 should change to "25"
    51-81 should remain the same but have 50 subtracted from them
    and 99 should change to "15".
    I could not figure out how to make elseif just leave the data as is so here is the gigantic if/then statement I created. Any help would be greatly appreciated.

    IIf([Recovered Birds]![R Day]="41","05","") & IIf([Recovered Birds]![R Day]="42","15","") & IIf([Recovered Birds]![R Day]="43","25","") & IIf([Recovered Birds]![R Day]="99","15","") & IIf([Recovered Birds]![R Day]="01","01","") & IIf([Recovered Birds]![R Day]="02","02","") & IIf([Recovered Birds]![R Day]="03","03","")& IIf([Recovered Birds]![R Day]="04","04","") & IIf([Recovered Birds]![R Day]="05","05","") & IIf([Recovered Birds]![R Day]="06","06","") & IIf([Recovered Birds]![R Day]="07","07","") & IIf([Recovered Birds]![R Day]="08","08","") & IIf([Recovered Birds]![R Day]="09","09","")& IIf([Recovered Birds]![R Day]="10","10","") & IIf([Recovered Birds]![R Day]="11","11","") & IIf([Recovered Birds]![R Day]="12","12","") & IIf([Recovered Birds]![R Day]="13","13","") & IIf([Recovered Birds]![R Day]="14","14","") & IIf([Recovered Birds]![R Day]="15","15","")& IIf([Recovered Birds]![R Day]="16","16","") & IIf([Recovered Birds]![R Day]="17","17","") & IIf([Recovered Birds]![R Day]="18","18","") & IIf([Recovered Birds]![R Day]="19","19","") & IIf([Recovered Birds]![R Day]="20","20","") & IIf([Recovered Birds]![R Day]="21","21","")& IIf([Recovered Birds]![R Day]="22","22","") & IIf([Recovered Birds]![R Day]="23","23","") & IIf([Recovered Birds]![R Day]="24","24","") & IIf([Recovered Birds]![R Day]="25","25","") & IIf([Recovered Birds]![R Day]="26","26","") & IIf([Recovered Birds]![R Day]="27","27","")& IIf([Recovered Birds]![R Day]="28","28","") & IIf([Recovered Birds]![R Day]="29","29","") & IIf([Recovered Birds]![R Day]="30","30","") & IIf([Recovered Birds]![R Day]="31","31","") & IIf([Recovered Birds]![R Day]="51","01","") & IIf([Recovered Birds]![R Day]="52","02","")& IIf([Recovered Birds]![R Day]="53","03","") & IIf([Recovered Birds]![R Day]="54","04","") & IIf([Recovered Birds]![R Day]="55","05","") & IIf([Recovered Birds]![R Day]="56","06","") & IIf([Recovered Birds]![R Day]="57","07","") & IIf([Recovered Birds]![R Day]="58","08","")& IIf([Recovered Birds]![R Day]="59","09","") & IIf([Recovered Birds]![R Day]="60","10","") & IIf([Recovered Birds]![R Day]="61","11","") & IIf([Recovered Birds]![R Day]="62","12","") & IIf([Recovered Birds]![R Day]="63","13","") & IIf([Recovered Birds]![R Day]="64","14","")& IIf([Recovered Birds]![R Day]="65","15","")& IIf([Recovered Birds]![R Day]="66","16","") & IIf([Recovered Birds]![R Day]="67","17","") & IIf([Recovered Birds]![R Day]="68","18","") & IIf([Recovered Birds]![R Day]="69","19","") & IIf([Recovered Birds]![R Day]="70","20","") & IIf([Recovered Birds]![R Day]="71","21","")& IIf([Recovered Birds]![R Day]="72","22","") & IIf([Recovered Birds]![R Day]="73","23","") & IIf([Recovered Birds]![R Day]="74","24","") & IIf([Recovered Birds]![R Day]="75","25","") & IIf([Recovered Birds]![R Day]="76","26","") & IIf([Recovered Birds]![R Day]="77","27","")& IIf([Recovered Birds]![R Day]="78","28","") & IIf([Recovered Birds]![R Day]="79","29","") & IIf([Recovered Birds]![R Day]="80","30","") & IIf([Recovered Birds]![R Day]="81","31","")

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Do you know how to make a public function in a standard module? Is the [R Day] field a text field or a numeric field?

  3. #3
    ack9f is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2010
    Posts
    2
    No, I am afraid I do not. The R_Day column is numeric. All data entry has been completed and no new entries will be added. I just need to convert the day codes to usable (0-31) days to prepare the data for analysis. I would manually change them, but there are over 200,000 entries.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I think Paul's page can get you started: http://www.baldyweb.com/Function.htm
    Just put the Public Function in a standard module so it can be used in a query. Post back here if you need further assistance.

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

Similar Threads

  1. Query Design View Takes a Long Time to Open
    By jackthedog in forum Queries
    Replies: 0
    Last Post: 12-22-2009, 03:27 PM
  2. switchboard is too long
    By razoRjaw in forum Forms
    Replies: 1
    Last Post: 11-01-2009, 06:34 PM
  3. Update Query- selective update?
    By stephenaa5 in forum Queries
    Replies: 1
    Last Post: 10-29-2009, 11:15 AM
  4. ODBC and Long Query Time
    By pdouglas in forum Access
    Replies: 0
    Last Post: 07-09-2009, 10:21 AM
  5. how long as this been around for.?
    By SOniC in forum Access
    Replies: 0
    Last Post: 04-12-2007, 11:38 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