Drop Down Box

yuppicideyuppicide Member Posts: 410
edited 2011-03-29 in Navision Attain
I am trying to figure out how to turn one of my TextBoxes into a drop down box with choices.

On my Item Card I have "Fabric Types" and you can drop down and select your fabric.. Rayon, Cotton, Sheer, Silk..

On another tab you guys helped me setup something earlier so I can have Catalog, Year, and Page number. I'd like Catalog to have a drop down box which contains selections PB, PC, PL, SP.

I looked at the code for Fabric Type and changed my Catalog to have OptionString ,PB,PC,PL,SP but that idd not work.

Comments

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    yuppicide wrote:
    I looked at the code for Fabric Type and changed my Catalog to have OptionString ,PB,PC,PL,SP but that idd not work.
    Make sure that the "Catalog" field in your table has the Data Type "Option".
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • yuppicideyuppicide Member Posts: 410
    Thanks for the help. That would work, except it won't let me change it because I have to blank out everything. There's too many items already labeled for me to go and blank every one out then re enter them.
  • SavatageSavatage Member Posts: 7,142
    Create a new field called Catalog2 with your options.
    Do a processing only report - that transfers the values from the incorrectly setup catalog field.

    catalog2 := catalog;
    modify;

    then you'll feel better that you don't have to do all the work again.
    Then delete the old catalog field - change the name of catalog2 to catalog.

    it's like a switcharoo - you know what I mean?
  • DenSterDenSter Member Posts: 8,307
    so you would take a multi-step approach:
    1 - add a new field, make it option type
    2 - create a routine that sets the new field to corresponding values to the existing field
    3 - validate the values
    4 - create a routine that blanks out the existing field
    5 - change the type of existing field to option, and run a routine to transfer the values from the new field

    or variations of this, there's more than one way to do it.

    <edit> like Harry says a "switcheroo" :mrgreen: </edit>
  • yuppicideyuppicide Member Posts: 410
    I have never tried to do a report like that, so I think I'll just leave it as is. Not that important anyway. I was only going to make the drop down box so people cannot type the wrong thing.

    Currently it only allows two characters, but if someone types it wrong then it won't show up on reports, or if someone types in lowercase when we're using only uppercase.

    Now that I think about it, they might not like only being able to choose certain things. If I'm not working here in the future they won't know how to change things.
  • SavatageSavatage Member Posts: 7,142
    Currently it only allows two characters, but if someone types it wrong then it won't show up on reports, or if someone types in lowercase when we're using only uppercase.

    Well next time - or perhaps when you have free time.
    It's not that hard to do. if you think about.

    So Use Option type in the future if you want to assign set choices
    or CODE type if you have entry field you want uppercase always.

    Not as good as actual "option" - but on the form if you edit the property ValuesAllowed for that field
    to PB;PC;PL;SP then that's all you can type into that field.

    or to force Uppercase:
    Property->CharAllowed
    Use this property to set the range of characters you will allow the user to enter into this field or text box.
    For example, if you want users to type only uppercase letters in this field, enter AZ

    Your report would be something like this.
    Create A new field in the item table called Catalog2 - type option with options ( ,PB,PC,PL,SP)
    Dataitem - ITEM
    OnAfterGetRecord()
    IF Catalog = 'PB' THEN Catalog2 := Catalog2::PB;
    IF Catalog = 'PC' THEN Catalog2 := Catalog2::PC;
    IF Catalog = 'PL' THEN Catalog2 := Catalog2::PL;
    IF Catalog = 'SP' THEN Catalog2 := Catalog2::SP;
    MODIFY;

    run the report - physically view that the new field has values so you don't need a Xanax.
    Now you have the values in both places.
    then you can use the same report just comment out the "if" code above using //
    Add Clear(Catalog);
    run again. now all your calalog values are clear. remove field from form so you don't get an error later on when you try to open the item card (not a hard fix if you don't do this).
    Now edit the Catalog Field - change it to type option Just like the Catalog2 field.
    Edit the report to copy the values from Catalog2 back to Catalog.
    a) or just delete catalog and rename catalog2 to catalog. Fix desired reports.
    b) now if copies to orig field then clear cat2 & delete field.
    basically, in,a,round,about,way.
  • yuppicideyuppicide Member Posts: 410
    Wow! That is easy. Actually, that knowledge might come in handy for other stuff I might need to do in the future, so good to know.
  • SavatageSavatage Member Posts: 7,142
    Use the power of reports & modify wisely!

    YOu can always filter with a report. so you can make some test items and filter on those to make sure what you doing is working correctly. A seperated test envion is always good.
Sign In or Register to comment.