Results 1 to 2 of 2
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Thanked 0 Times in 0 Posts

    rationalkize select statement (Access 2000)

    Avoid repeating one and the same select case statement

    In my main form i have a certain fixed row of options and i am refering to these options a lot of times and on different occasions.
    therefore i am forced to write down the select case statement many times.I wonder is there a way to rationalize the select case
    statement, to write it down only once and then refer to this constant code repeatedly in different functions. That is each function to be able to refer to the set
    conditions given in the main form with the help of the options.
    here is an example of a function that might be rationalized:
    class0,rowo etx are control sources in the form.For example in case 1 the control source will be equal to class0, but in case 2 it will be equal to class1.

    Public Function FWarehouse(Bestand, Stueck)
    Select Case Forms![main]![Options]
    Case 1
    Bestand.ControlSource = "class0"
    Stueck.ControlSource = "row0"
    Case 2
    Bestand.ControlSource = "class1"
    Stueck.ControlSource = "row1"
    Case 3
    Bestand.ControlSource = "class2"
    Stueck.ControlSource = "row2"
    Case 4
    Bestand.ControlSource = "class3"
    Stueck.ControlSource = "row3"
    Case 5
    Bestand.ControlSource = "class4"
    Stueck.ControlSource = "row4"
    Case 12
    Bestand.ControlSource = "class11"
    Stueck.ControlSource = "row111"

    End Select
    End Function

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Crystal Beach, FL, Florida, USA
    Thanked 41 Times in 40 Posts

    Re: rationalkize select statement (Access 2000)

    How about this instead:

    Public Function FWarehouse(Bestand, Stueck)
    Bestand.controlsource = "class" & (Forms!main!Options - 1)
    Stueck.controlsource = "row" & (Forms!main!Options - 1)
    End Function
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts