Results 1 to 5 of 5

Thread: SQL help

  1. #1
    Join Date
    Sep 2011
    Posts
    48

    Unanswered: SQL help

    Hi,

    So far these boards have been great! Helped me out so much, mostly Sinndho!

    I have another question, hopefully it can be done.

    I have the following code:

    Switch(Bank='244','USD',Bank='148','CAN') AS curr_abbr

    I just received new parameters and I want there to be multiple options when Bank='244'. Am I able to make it so it has, 3/4 options as a drop down box? I create a form based on the query that has the SQL in it.

    Like when Bank=244 it can be USD, CAN, GER etc.

    thanks.

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Not sure to understand. As you present it, the Switch function seems to be used as part of a SQL statement in a query. When does a combobox comes in to play?

    If you intend to use it on a form, as the Switch function included in the query seems to act as the RecordSource for that form, is there a textbox currently bound to curr_abbr (the result of the function in the query)?

    Finally where does the value selected in the combobox returns? At the moment the query is read-only, because of the function. Do you indend to store the value back into a table?

    I'm sorry but you'll have to elaborate a little bit more; I cannot provide a sensible answer with what I now know.
    Have a nice day!

  3. #3
    Join Date
    Sep 2011
    Posts
    48
    aww ok.

    I should have posted the full SQL

    SELECT Details.bank,
    Switch(Bank='244','USD',Bank='148','CAN') AS curr_abbr
    FROM Details;

    So at the moment if someone types in the form, to the text box called "Bank", 244 it will change the curr_abbr to USD. I want the user to be able to chose between 3 different currencies such as USD, CAN etc.

    The value is changed in the table details, and I want it to stay that way.

    Sorry if it is still unclear.

  4. #4
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    You'd need to store more than '244' in the Bank field in order to determine or store the result for later, regardless of what user input you get...

    I'd suggest adding a BANK table and using the combo box to do a lookup from it... or perhaps it makes more sense to have a CurrAbbr field in the table so you can choose a bank and also a currency?
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  5. #5
    Join Date
    Sep 2011
    Posts
    48
    Quote Originally Posted by StarTrekker View Post
    You'd need to store more than '244' in the Bank field in order to determine or store the result for later, regardless of what user input you get...

    I'd suggest adding a BANK table and using the combo box to do a lookup from it... or perhaps it makes more sense to have a CurrAbbr field in the table so you can choose a bank and also a currency?
    Thanks!! Yeah I did this and it works great.

    Nevermind figured it out!
    Last edited by grooner10; 09-13-11 at 11:14.

Posting Permissions

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