• Multiple Ifs (Access 2000)

    Author
    Topic
    #365071

    Is there a way to have an equivalent to IF .. else. For example I need to have a formula calculate using the equivalent of :
    if criteria 1 is true, do calculation1; else if criteria 2 is true do calculation 2; else if criteria 3 is true do calculation 3 etc
    TIA

    Viewing 1 reply thread
    Author
    Replies
    • #562399

      I think what you’re looking for is the ‘switch()’ function. If you Iook it up in Access help, you get this example:

      = Switch([ShipCity] = “Madrid”, “Spanish”, _
      [ShipCity] = “Berlin”, “German”, _
      [ShipCity] = “Torino”, “Italian”, _
      [ShipCountry] = “France”, “French”, _
      True, “English”)

      king eric

    • #562400

      Hi Steve,
      I think you’re looking for the Select Case statement. It works just the way you’ve described. For Example:

      '....
           intCriteria = 3
           Select Case intCriteria
                Case 1
                     'Do Calculation1
                Case 2
                     'Do Calculation2
                Case 3
                     'Do Calculation 3 - since intCriter = 3, this one will be selected
                Case Else
                     'Covers any other case (not always needed, but good to have)
           End Select
      '......

      Check the Access Helpfile for more detailed specifics.

      HTH salute

      • #562640

        Thanks for quick response but I must be having a bad hair day – no refence to select case in the help file – though in all honesty I hate the new help file technique in Access 2000 and am probably using old fart searching techniques based on Access 97 aussie

        • #562642

          Oops – found it – as everyone but me probably knew , you have to be in VB to get help about it. Thanks again

          • #562659

            Steve,

            I haven’t met anyone yet who likes the new Help files, including the people I’ve talked to at Microsoft. crazy The trick is to use the answer wizard and, as you discovered, the topics returned will depend on whether you’rein the UI or the VBE. Try framing your search string along the lines of “how do I ….” You don’t have to include those words, but I’ve found that approach to give me the best results with the thing.

    Viewing 1 reply thread
    Reply To: Multiple Ifs (Access 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: