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

Combo

Status
Not open for further replies.

baudouxf

Programmer
Jan 17, 2003
12
BE
Hi experts,

Do I miss something about the fact that a combo with a recourdsource data type Integer doesn't work even if rightly bounded to an Integer data field?

It works only if data type is Character !

If I'm right, does anybody have a workaround ?

Thanks for inputs

Francis
 
Integer should work fine. For instance set the RowSource = MyTable, the RowSourceType = 2 - Alias, and then Mytable.MyField in the controlsource. If the MyField is an integer field you should see the numbers coming up just fine.

Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
Thanks for you fast reply,

Ok, I agree but the problem comes when you want to diplay a data field in 1st column instead of the Integer data.

For example :

2 tables : 1st : Systems
2nd : Refs

Systems has an integer field (Refs_key) pointing to refs.key (also Integer). The data to be displayed into the Combo is Refs.name (String).
The Combo contralsource is Systems.refs_key and Rowsource are : Refs.name, Refs.key

If Refs.key and Systems.refs_key are not Characters strings, it doesn't work
 
baudouxf,

Take the code below and cut-n-paste it into a prg file and run it from within VFP. It works for me. Maybe it will help you fix your problem or maybe I am still missing something.


PUBLIC oForm
oForm = CREATEOBJECT("clscombotest")
oForm.show()

DEFINE CLASS clscombotest AS form


DoCreate = .T.
Caption = "Form"
Name = "clscombotest"


ADD OBJECT combo1 AS combobox WITH ;
BoundColumn = 2, ;
ColumnCount = 2, ;
ColumnWidths = "125,100", ;
RowSourceType = 6, ;
RowSource = "Refs.name, key", ;
ControlSource = "refs.key", ;
Height = 24, ;
Left = 56, ;
Top = 68, ;
Width = 252, ;
BoundTo = .T., ;
Name = "Combo1"


PROCEDURE Load
CREATE CURSOR Refs (name c(25), key I)
INSERT INTO Refs (name, key) VALUES ("Bill Smith", 2345675)
INSERT INTO Refs (name, key) VALUES ("Sue Ellen", 314231)
INSERT INTO Refs (name, key) VALUES ("Donald Boyd", 436343)
INSERT INTO Refs (name, key) VALUES ("Claire Seagull", 89866879)
ENDPROC


ENDDEFINE



Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
Ok I fully agree. But but but take the following in wich I inserted a controsource (m_control I), set the value to 436343, it doesn't display you 'Donald Boyd'.

PUBLIC oForm, m_control
oForm = CREATEOBJECT("clscombotest")
oForm.show()

m_control = 436343

DEFINE CLASS clscombotest AS form


DoCreate = .T.
Caption = "Form"
Name = "clscombotest"


ADD OBJECT combo1 AS combobox WITH ;
ControlSource = m_control,;
BoundColumn = 2, ;
ColumnCount = 2, ;
ColumnWidths = "125,100", ;
RowSourceType = 6, ;
RowSource = "Refs.name, key", ;
ControlSource = "refs.key", ;
Height = 24, ;
Left = 56, ;
Top = 68, ;
Width = 252, ;
BoundTo = .T., ;
Name = "Combo1"


PROCEDURE Load
CREATE CURSOR Refs (name c(25), key I)
INSERT INTO Refs (name, key) VALUES ("Bill Smith", 234567)
INSERT INTO Refs (name, key) VALUES ("Sue Ellen", 314231)
INSERT INTO Refs (name, key) VALUES ("Donald Boyd", 436343)
INSERT INTO Refs (name, key) VALUES ("Claire Seagull", 898668)
ENDPROC


ENDDEFINE

Now, use the following (with strings): it displays you the right item ('Donald Boyd')


PUBLIC oForm, m_control
oForm = CREATEOBJECT("clscombotest")
oForm.show()

m_control = '436343'

DEFINE CLASS clscombotest AS form


DoCreate = .T.
Caption = "Form"
Name = "clscombotest"


ADD OBJECT combo1 AS combobox WITH ;
ControlSource = m_control,;
BoundColumn = 2, ;
ColumnCount = 2, ;
ColumnWidths = "125,100", ;
RowSourceType = 6, ;
RowSource = "Refs.name, key", ;
ControlSource = "refs.key", ;
Height = 24, ;
Left = 56, ;
Top = 68, ;
Width = 252, ;
BoundTo = .T., ;
Name = "Combo1"


PROCEDURE Load
CREATE CURSOR Refs (name c(25), key C(6))
INSERT INTO Refs (name, key) VALUES ("Bill Smith", '234567')
INSERT INTO Refs (name, key) VALUES ("Sue Ellen", '314231')
INSERT INTO Refs (name, key) VALUES ("Donald Boyd", '436343')
INSERT INTO Refs (name, key) VALUES ("Claire Seagull", '898668')
ENDPROC


ENDDEFINE


Isn't it interesting ?

Francis
 

baudouxf

There are few things I've noticed from your code

1. The ControlSource of the Combo1 object, was assigned two times
ADD OBJECT combo1 AS combobox WITH ;
1 -> ControlSource = m_control,;
BoundColumn = 2, ;
ColumnCount = 2, ;
ColumnWidths = "125,100", ;
RowSourceType = 6, ;
RowSource = "Refs.name, key", ;
2 -> ControlSource = "refs.key", ;
Height = 24, ;
Left = 56, ;
Top = 68, ;
Width = 252, ;
BoundTo = .T., ;
Name = "Combo1"

2. You must bind the ControlSource to the variable itself not to the the value of variable. You must put the variable between quotes
ADD OBJECT combo1 AS combobox WITH ;
BoundColumn = 2, ;
ColumnCount = 2, ;
ColumnWidths = "125,100", ;
RowSourceType = 6, ;
RowSource = "Refs.name, key", ;
ControlSource = "m_control",;
Height = 24, ;
Left = 56, ;
Top = 68, ;
Width = 252, ;
BoundTo = .T., ;
Name = "Combo1"

Hope that helps
Regards

-- AirCon --
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top