Results 1 to 4 of 4
  1. #1
    billybeer is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2015
    Posts
    27

    simple Switch function question


    I have a report that I want to use the Switch function in one of the fields. I have a query that will return the criminal statute number for a crime (i.e. 750/82) I want to switch that to the title of the crime (Domestic violence). My issue is that there are hundreds of statute numbers and I only want to switch the most 40 or so most used statutes. When I use the switch function it works with the statutes I put in but returns a blank for the ones I haven't put into the function. Is there a way to switch from number to title on the ones I have done and simply return the statute number for the ones I haven't included in the switch function?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    you should use lookup tables for this ,instead of hard coded switch function.
    join the data table to the code table, then perform an update.

  3. #3
    billybeer is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2015
    Posts
    27
    Thanks for the direction.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    ranman, what do you mean by 'perform an update'? There is no reason to save the crime title into data table. Just build query that links tables. Then expression in query or textbox:

    Nz([CrimeTitle], [Statute])

    How many hundreds? Would it be worthwhile to enter the title for all codes?

    Now the decision to make is whether to save the statute code which is a text value or an autonumber ID key from the lookup table.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 12
    Last Post: 05-14-2017, 10:11 AM
  2. Alernative to SWITCH function???
    By elender in forum Queries
    Replies: 5
    Last Post: 02-09-2017, 06:54 PM
  3. Simple passing into function question
    By Ruegen in forum Programming
    Replies: 3
    Last Post: 07-24-2014, 11:23 PM
  4. Using SQL switch function MS Access
    By sandlucky in forum Queries
    Replies: 18
    Last Post: 03-31-2011, 08:49 AM
  5. Select Query in Switch Function
    By sandlucky in forum Queries
    Replies: 0
    Last Post: 03-30-2011, 04:54 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