Home » Developer & Programmer » Forms » dynamic drop down
dynamic drop down [message #83494] Fri, 17 October 2003 11:25 Go to next message
SA
Messages: 37
Registered: March 2002
Member
Hi,

I have a data block which has one field of drop down type. It should come from a query (query1). Also, when the form opened, it sets the value of the drop-down from database(using execute_query build-in, but different from query1). Can someone give me an idea or example how to implement it? Thank you in advance!

Sa
Re: dynamic drop down [message #83497 is a reply to message #83494] Fri, 17 October 2003 19:15 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
You can use :block_name.item_name in record_groups (the source of LOVs).

If not clear, provide more info.

MHE
Re: dynamic drop down [message #83509 is a reply to message #83497] Mon, 20 October 2003 09:54 Go to previous messageGo to next message
SA
Messages: 37
Registered: March 2002
Member
Thank you for your reply. My question is I have a drop down which come from a database table (for example select event_type from event_type_table) and this drop down is in a data block (say the query associate with this datablock is "select event_date, event_type, event_place from event_table where user = 'somebody'). So when the form loads it, in event block, it should show some info from database table event_table. And event_type is a drop down and it should show the value from the above query. I'm new to this, so I don't know what the good way to implement this. Can you help me with this? I'm going to post this again since I need to have this done asap. Thanks

Sa
Re: dynamic drop down [message #83518 is a reply to message #83509] Tue, 21 October 2003 00:42 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
1. Create a text item on the form (e.g. txt_event_type)

2. Create a record group with the select desired:
SELECT event_type
  FROM event_type_table


3. Create a LOV (List Of Values) lov_events with this record group. You can use the LOV wizard for that. Make sure you display all the desired items. Assign the LOV (return items) to the item on the form. Modify the LOV ad lib. If your new, it's best to keep the defaults.

4. In the property palette of your item txt_event_type, set the LOV property to lov_events. You can force the user to use the LOV by setting the "validate from list" property to "yes".

Now, if you run the Form, the LOV will be invoked when you press F9 when you have positioned the cursor in the txt_event_type item. You could use a small button to make the text item appear like a drop down list. In the buttons' WHEN-BUTTON-PRESSED trigger you invoke the LOV by code like
Begin
  Go_Item('your_block.txt_event_types');
  Do_Key('List_Values');
End;
LOVs are very common in the Forms environment. They are invented just for this particular usage.

MHE
Re: dynamic drop down [message #83525 is a reply to message #83518] Tue, 21 October 2003 14:46 Go to previous message
SA
Messages: 37
Registered: March 2002
Member
Thank you. That works. But I want to use drop down instead. I have code to populate drop down list using record group and if there is no record in the data block, it's perfectly fine. But if there are some records there, I don't know how to set value of the drop down since execute_query won't work. I have a workaround, which for each record, I populate the drop-down and set value of the drop-down to the value get from database. I don't know if there is a better way to do that. Do you have any suggestions? Thanks,
Previous Topic: ARABIC LANGUAGE
Next Topic: How to do that.
Goto Forum:
  


Current Time: Fri Mar 29 07:26:44 CDT 2024