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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create a ComboBox Control from two fields of a table

Status
Not open for further replies.

Ducu

Programmer
Oct 2, 2003
30
RO
Hi,
Could you help me how to construct a ComboBox Control from two fields of a table:

I've tried something like this but at the line
Code:
frmMyForm.cbxnAnul.RowSource=field state.nume_luna, state.an
i get a syntax error message

Thank you,

Dan C. Nagy

Code:
use state.dbf in 1 alias state exclusive
select state

frmMyForm = CREATEOBJECT('MyForm') 
frmMyForm.AddObject('cbxnAnul','ComboBox')

frmMyForm.cbxnAnul.Visible=.T.
frmMyForm.cbxnAnul.Left=220        
frmMyForm.cbxnAnul.Top=32
frmMyForm.cbxnAnul.Width=50
frmMyForm.cbxnAnul.FontSize=8
frmMyForm.cbxnAnul.RowSourceType=6
&& i get a syntax error message at the next line
frmMyForm.cbxnAnul.RowSource=field state.nume_luna, state.an


frmMyForm.cbxnAnul.ControlSource=m.lunaaleg

frmMyForm.Show(1)

DEFINE CLASS cmdMyCmndBtn AS CommandButton  && Create Command button
   Caption = '\<Iesire'  && Caption on the Command button
   Cancel = .T.  && Default Cancel Command button (Esc)
   Left =615  && Command button column
   Top = 450 && Command button row
   Height = 20  && Command button height\da
   Width=70
   FontSize=8
   
   PROCEDURE Click
  
      THIS.Parent.Release()

ENDDEFINE

DEFINE CLASS cmdMyCmndBtn1 AS CommandButton  && Create Command button
   Caption = '\<Continua'  && Caption on the Command button
   Cancel = .T.  && Default Cancel Command button (Esc)
   Left = 285 && Command button column
   Top = 32 && Command button row
   Height = 20  && Command button height\da
   Width=70
   FontSize=8
   
   PROCEDURE Click
ENDDEFINE

DEFINE CLASS MyForm AS Form
	Width=750
	Height=500
	Caption="LISTARE AVANS"
	Closable = .F.  && Disable the Control menu box
	BorderStyle=2
	DataSession=1
	&& DataEnvironment=DE

    ADD OBJECT cmdCommand1 AS cmdMyCmndBtn
    ADD OBJECT cmdCommand2 AS cmdMyCmndBtn1
    
    ADD OBJECT lblTitlu AS Label WITH ;
      Visible=.T.,;
      Left=10,;        
	  Top=4,;
      FontBold=.T.,;
      FontSize=16,;
      BackStyle=0,;
      AutoSize=.T.,;
      Caption="LISTARE AVANS"

   ADD OBJECT lblluna AS Label WITH ;
      Visible=.T.,;
      Left=10,;        
	  Top=34,;
      FontBold=.T.,;
      FontSize=8,;
      BackStyle=0,;
      AutoSize=.T.,;
      Caption="Pe luna:" 
    
   ADD OBJECT lblan AS Label WITH ;
      Visible=.T.,;
      Left=165,;        
	  Top=34,;
      FontBold=.T.,;
      FontSize=8,;
      BackStyle=0,;
      AutoSize=.T.,;
      Caption=" din anul:"    
   

ENDDEFINE
 
Mike,

Thank you for advice. I don't get the error message, but the displayed values in the combobox are those of the first field. For the second field no values is displayed. What I mean is like the second field declarations is not there. I interchanged the declarations of the two fields but same problem. Only the first field is used to construct the combobox control.
Any suggestions ?

Thank you,

Dan
 
Mike,

I was looking in the messages and I figure it out ! The ColumnCount property was not set to correct value.

Thanks,
Dan

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top