Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Itens in Combo Box 1

Status
Not open for further replies.

SitesMasstec

Programmer
Sep 26, 2010
508
Brasil
Hello colleagues:

I have two ComboBox named cboCia and cboNavio:
ComboBox1_juodzp.jpg


When I run the form, ComboBox named cboCia is populated with names of companies read from a file.

When I choose an item (company name) in the ComboBox named cboCia, it shows:

ComboBox2_qew4tk.jpg


and it has to populate the ComboBox named cboNavio with names of ships:

So, in the form I clicked on AW - AMAWATERWAYS, it opens a file which stores this company collection of ships, and I need to show them in the ComboBox named cboNavio.

In the LostFocus procedure in cboCia, the code:
Code:
SELECT 120
Select XIDENTNAV from TEMPNAVIOS into cursor CURNAVIOS
thisform.cboNavio.RowSourceType= 6    && Fields
thisform.cboNavio.RowSource=CURNAVIOS.XIDENTNAV

This is TEMPNAVIOS.DBF file (it has data, but these data is not populated in the ComboBox names cboNavio:
TempNavios1_zedv9z.jpg


What am I missing?



Thank you,
SitesMasstec
 
A fields rowsourcetype is a string of field names, not the field itself.

Code:
thisform.cboNavio.RowSource=[COLOR=#EF2929][highlight #FCE94F]"[/highlight][/color]CURNAVIOS.XIDENTNAV[COLOR=#EF2929][highlight #FCE94F]"[/highlight][/color]

Chriss
 
Better yet:
Code:
* SELECT 120 - no idea why you think this is necessary, SQL puts a result in a new empty workarea aka SELECT 0.

Select XIDENTNAV, XNUMNAV from TEMPNAVIOS into cursor CURNAVIOS
thisform.cboNavio.RowSourceTyp e= 6    && Fields
thisform.cboNavio.RowSource="CURNAVIOS.XIDENTNAV,XNUMNAV"
thisform.cboNavio.ColumnWidths=TRANSFORM(thisform.cboNavio.Width)+",0"
thisform.cboNavio.BoundColumn=2

That way the displayed values are the ship names (user friendly), but the cboNavio.value finally becomes the id in XNUMNAV, the technically unique value that specifies exactly which ship is meant, which is "code friendly". You should always think about that difference, what the user needs to see and what you need for your coide and data and fields like primary or foreign keys.

Chriss
 
Chris:

Great!

Now it works fine:
ComboBox3_bpz0tf.jpg


And I will follow your advice about getting other data used in code.


Thank you,
SitesMasstec
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top