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

    Select Case (Access 2000)

    I need to cary out some actions only when the user selects a speial customer.These customers are 10 in number out of 1000, but their number do not folllow any logical pattern.For example one of the custoemrs has a number 147,another has 5000 and so on

    I have tried to build a Select Case statement but it seems to me i have not written them properly.For example do i need to repeat each the name CustomerID ?


    Select Case Forms![Form1]![Customerid]
    Case 1
    CustomerID = 147
    DoCmd....
    Case 2
    CustomerID = 218
    DoCmd.....
    End select

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Select Case (Access 2000)

    Close, but try this:<pre>Select Case Form1!CustomerID
    Case 147
    DoCmd...
    Case 218
    DoCmd...
    Case Else
    DoCmd '(or not)
    End Select</pre>

    If you're SURE these special customer numbers will never change hard-coding them is a good idea. You may also consider storing the special numbers in a separate table, or designating them with a checkbox field in the current table. Then you could still check their "status" using a Select case or an If statement. (for instance: If Form1!blnSpecialCustomer Then...)

    HTH

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Select Case (Access 2000)

    Do you do something different for each of these customers or do you simply do something different for *any* of them? If you don't have special handling that's unique to an individual customer, your case can include all the numbers, like this:

    Select Case Me!CustomerID
    Case 147, 5000 'add any unique number to list
    DoCmd. ...
    Case Else
    End Select

    I'm assuming here that the code is run from within Form1 rather than from somewhere else.
    Charlotte

Posting Permissions

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