How to use lookup on a textbox

gurleengurleen Member Posts: 39
I have a textbox which is attached to a table field underneath. I want the user to have 4 fixed options. I have tried everyway but cannot get the textbox to show a dropdown box with the desired values in it. The textbox connects back to a a field that is of type text ( it's not of type option).

Comments

  • charlpcharlp Member Posts: 21
    You can use the OnLookUp event to open a form linked to a table containing only yout four options. When the use makes a selection, simply pass the selection back through the event's TEXT parameter.

    It's a bit of a waste of a table ID though.

    Why can't you change the field to type Option?
  • DenSterDenSter Member Posts: 8,307
    no no no no :). Create a variable with datatype option, and put your option values in the optionstring property of the variable. Then add a text box to your form and set the SourceExpr property of the text box to the new variable.

    <edit>
    Much better even:
    Change the data type of your field to option, and enter the option values there. Then it's just a matter of dragging the field from the field list onto your form.
    </edit>
  • gurleengurleen Member Posts: 39
    I think I might not have explained properly. T

    The form connects to a temporary record type underneath. One of the fields in the table can have only four values . I want the user to have the option of selecting the values from a dropdown rather than remembering them.

    If I link the source expresion property to the option field then I wont be able to save the record back to the table ( with minimum code).

    Also can I have an option field where I can fill the options at runtime.
  • DenSterDenSter Member Posts: 8,307
    Well that's your design decision, but it sounds too complicated to me. If all yo're ever going to get is these 4 options, you need to create an option type field on the table, with only those 4 options as possible selections. It's never ever going to be anything but the selections in the option string, so it doesn't need to be dynamic. It is so much easier to just put your selections in an option field on the table itself. Take a look at the Type field on the Sales Line table for instance.

    If you go the way you explained, with temporary records, then you will have to program the form or report or whatever to populate the temporary table.
  • DenSterDenSter Member Posts: 8,307
    oh another thing... it is not possible to present a table lookup in a dropdown control, that's just not possible with objects available in the Navision IDE. The best you can do with a table lookup is a lookup button, which is the one with the arrow pointing up.
  • gurleengurleen Member Posts: 39
    I worked that one out. Now I load the form with the textbox attached to an option field. When the form closes I set the value of the table-record field from the option and update the record..

    What about options at runtime. I have to show an option for all the locations of the company. The locations table does not include the company address, it just shows alternate ones. How do I combine the locations into one dropdown. Right now my dropdown only shows values from the Location table ( ie I am missing the company address )
  • DenSterDenSter Member Posts: 8,307
    I don't understand why you have to do it so complicated. You need to update a field with a value out of an option field, why not just make the field an option field and be done with it? That's no programming at all, and you could have been done in two seconds instead of two days.
  • gurleengurleen Member Posts: 39
    But how can I have an option field that can keep track of all the locations for the company.

    My form has three Textboxes on it.

    1. One which has static choices ( I converted the field to option and it works fine)
    2. The second and the third textboxes can take any location code for the company. The problem is that the location code comes from two different tables ( Locations & Company Address ) and can change if the user adds or deletes any address.

    My question is how to create a dropdown in the second and the third textbox.
  • DenSterDenSter Member Posts: 8,307
    That's comparing apples and oranges. A Location is a warehouse location, a storage facility. The company address is the address of the legal entity. If you need to have a storing facility at the same address as the company, why not just enter one in the location table and be done with it? That takes just 15 seconds as opposed to developing a solution where you compine data from two incompatible entities and force the system to treat them the same.

    What is going to happen with your on hand quantities? How are you going to do the replenishment? There are many other questions when you try to make these types of changes.

    I don't mean to dismiss the issue, maybe I misunderstand it, but there are very easy solutions for the issues that you seem to have.
  • gurleengurleen Member Posts: 39
    I need all the locations for some other purposes. A user should be allowed to choose any address related to a company which will include the main adderss and all the locations.This is a buisness requirement which I can't ignore.
  • DenSterDenSter Member Posts: 8,307
    Then I suggest you use a different name than Location. This is the name of a very specific piece of Navision functionality, and may cause confusion :).

    I still don't understand what you need to do, but here are some general tips:
    Before you can display the temp record on any form, you need to fill the temporary Rec variable with information from wherever you want to get the information from.

    Then you open the form for the temp variable. If you use the table's lookup form, and you set the lookupmode property to TRUE, then you will see the OK button, and you can do the RUNMODAL and the ACTION::OK thing, and consequently capture the code of the "location" and program the rest of it.
Sign In or Register to comment.