Hi,

I have a ComboBox with a Cursor as RowSource
and a Table.Field as ControlSource.
How can I let the user enter a value in the combobox that is not
in the Cursor ?

The Cursor holds "quick pick" values but I want to let the user add
other values besides those Cursor values.
Each time when the entered value isn't in the rowlist the value becomes
blank.

problably a silly question
but I can't seem to figure out how to.

kind regards
christophe

Re: combobox,rowsource,displayvalue,controlsource by Stefan

Stefan
Mon Apr 14 03:28:39 CDT 2008


"christophe" <nothingtosend@empty.com> schrieb im Newsbeitrag
news:%23V$cBHgnIHA.1212@TK2MSFTNGP05.phx.gbl...
> Hi,
>
> I have a ComboBox with a Cursor as RowSource
> and a Table.Field as ControlSource.
> How can I let the user enter a value in the combobox that is not
> in the Cursor ?
>
> The Cursor holds "quick pick" values but I want to let the user add
> other values besides those Cursor values.
> Each time when the entered value isn't in the rowlist the value becomes blank.

When user's input does not exist in the combo.RowSource yet,
you'd need to insert it there (or AddItem() or re-dimension the
rowsource array depending on the .RowSourceType), e.g.
in combo.Valid() pseudo code:

If This.ListIndex=0 And Not Empty(This.DisplayValue)

or
If Not (This.Value == This.DisplayValue)
Insert Into ....



hth
-Stefan




--
|\_/| ------ ProLib - programmers liberty -----------------
(.. ) Our MVPs and MCPs make the Fox run....
- / See us at www.prolib.de or www.AFPages.de
-----------------------------------------------------------



Re: combobox,rowsource,displayvalue,controlsource by christophe

christophe
Mon Apr 14 04:41:16 CDT 2008

Thanks Stefan,

I thought of that but "hoped" there was something more logical....

kind regards
christophe

"Stefan Wuebbe" <stefan.wuebbe@gmx.de> schreef in bericht
news:uUaaMmgnIHA.4480@TK2MSFTNGP03.phx.gbl...
>
> "christophe" <nothingtosend@empty.com> schrieb im Newsbeitrag
> news:%23V$cBHgnIHA.1212@TK2MSFTNGP05.phx.gbl...
>> Hi,
>>
>> I have a ComboBox with a Cursor as RowSource
>> and a Table.Field as ControlSource.
>> How can I let the user enter a value in the combobox that is not
>> in the Cursor ?
>>
>> The Cursor holds "quick pick" values but I want to let the user add
>> other values besides those Cursor values.
>> Each time when the entered value isn't in the rowlist the value becomes
>> blank.
>
> When user's input does not exist in the combo.RowSource yet,
> you'd need to insert it there (or AddItem() or re-dimension the
> rowsource array depending on the .RowSourceType), e.g.
> in combo.Valid() pseudo code:
>
> If This.ListIndex=0 And Not Empty(This.DisplayValue)
>
> or
> If Not (This.Value == This.DisplayValue)
> Insert Into ....
>
>
>
> hth
> -Stefan
>
>
>
>
> --
> |\_/| ------ ProLib - programmers liberty -----------------
> (.. ) Our MVPs and MCPs make the Fox run....
> - / See us at www.prolib.de or www.AFPages.de
> -----------------------------------------------------------
>



Re: combobox,rowsource,displayvalue,controlsource by christophe

christophe
Tue Apr 15 04:12:37 CDT 2008

Stefan,

I have put this code in the combo.valid()

IF .not. seek(this.DisplayValue,"rowsourcetable")
INSERT INTO "rowsourcetable" (klantnr) VALUES (this.displayvalue)
this.Requery()
ENDIF

but still it is blanked when leaving the combobox.
Although the rowsource is correct.

christophe


"Stefan Wuebbe" <stefan.wuebbe@gmx.de> schreef in bericht
news:uUaaMmgnIHA.4480@TK2MSFTNGP03.phx.gbl...
>
> "christophe" <nothingtosend@empty.com> schrieb im Newsbeitrag
> news:%23V$cBHgnIHA.1212@TK2MSFTNGP05.phx.gbl...
>> Hi,
>>
>> I have a ComboBox with a Cursor as RowSource
>> and a Table.Field as ControlSource.
>> How can I let the user enter a value in the combobox that is not
>> in the Cursor ?
>>
>> The Cursor holds "quick pick" values but I want to let the user add
>> other values besides those Cursor values.
>> Each time when the entered value isn't in the rowlist the value becomes
>> blank.
>
> When user's input does not exist in the combo.RowSource yet,
> you'd need to insert it there (or AddItem() or re-dimension the
> rowsource array depending on the .RowSourceType), e.g.
> in combo.Valid() pseudo code:
>
> If This.ListIndex=0 And Not Empty(This.DisplayValue)
>
> or
> If Not (This.Value == This.DisplayValue)
> Insert Into ....
>
>
>
> hth
> -Stefan
>
>
>
>
> --
> |\_/| ------ ProLib - programmers liberty -----------------
> (.. ) Our MVPs and MCPs make the Fox run....
> - / See us at www.prolib.de or www.AFPages.de
> -----------------------------------------------------------
>



Re: combobox,rowsource,displayvalue,controlsource by Stefan

Stefan
Tue Apr 15 05:28:52 CDT 2008


"christophe" <nothingtosend@empty.com> schrieb im Newsbeitrag
news:ORbPmjtnIHA.4196@TK2MSFTNGP04.phx.gbl...
> Stefan,
>
> I have put this code in the combo.valid()
>
> IF .not. seek(this.DisplayValue,"rowsourcetable")
> INSERT INTO "rowsourcetable" (klantnr) VALUES (this.displayvalue)
> this.Requery()
> ENDIF
>
> but still it is blanked when leaving the combobox.
> Although the rowsource is correct.

The example.prg below works for me, same for you?
If so, can you modify it to match your requirements and make it
reproduce the misbehaviour you observed?


hth
-Stefan



*
PUBLIC oform1
oform1=NEWOBJECT("form1")
oform1.Show()
RETURN

DEFINE CLASS form1 AS form
ADD OBJECT combo1 AS combobox WITH ;
RowSourceType = 3, ;
RowSource = "select * from temp into cursor (sys(2015))", ;
Height = 24, ;
Left = 72, ;
Top = 60, ;
Width = 100

ADD OBJECT text1 AS textbox WITH ;
Height = 23, ;
Left = 156, ;
Top = 156, ;
Width = 100, ;
Value = 'focus dummy'

PROCEDURE Load
LOCAL lnSelect
lnSelect = SELECT(0)
CREATE CURSOR temp (test C(10))
INDEX on test TAG test
FOR i = 1 TO 3
INSERT INTO temp VALUES (TRANSFORM(i))
ENDFOR
GO TOP
SELECT (m.lnSelect)
ENDPROC

PROCEDURE combo1.Valid
LOCAL lcValue
lcValue = TRIM(This.DisplayValue)
IF !EMPTY(m.lcValue) AND !INDEXSEEK(m.lcValue,.F.,'temp','test')
INSERT INTO temp VALUES (m.lcValue)
This.Requery()
ENDIF
ENDPROC
ENDDEFINE
*



--
|\_/| ------ ProLib - programmers liberty -----------------
(.. ) Our MVPs and MCPs make the Fox run....
- / See us at www.prolib.de or www.AFPages.de
-----------------------------------------------------------



Re: combobox,rowsource,displayvalue,controlsource by christophe

christophe
Tue Apr 15 05:53:18 CDT 2008

Hi,

I've marked with an ** which code i've added.
Then you'll see the behaviour I don't want.
I just add a combobox controlsource with a table.

PUBLIC oform1
CREATE CURSOR "test" (nummer C(10)) **
APPEND BLANK **
oform1=NEWOBJECT("form1")
oform1.Show()
RETURN
DEFINE CLASS form1 AS form
ADD OBJECT combo1 AS combobox WITH ;
boundto = .t.,; **
controlsource = "test.nummer",; **
RowSourceType = 3, ;
RowSource = "select * from temp into cursor (sys(2015))", ;
Height = 24, ;
Left = 72, ;
Top = 60, ;
Width = 100
ADD OBJECT text1 AS textbox WITH ;
Height = 23, ;
Left = 156, ;
Top = 156, ;
Width = 100, ;
Value = 'focus dummy'
PROCEDURE Load
LOCAL lnSelect
lnSelect = SELECT(0)
CREATE CURSOR temp (test C(10))
INDEX on test TAG test
FOR i = 1 TO 3
INSERT INTO temp VALUES (TRANSFORM(i))
ENDFOR
GO TOP
SELECT (m.lnSelect)
ENDPROC
PROCEDURE combo1.Valid
LOCAL lcValue
lcValue = TRIM(This.DisplayValue)
IF !EMPTY(m.lcValue) AND !INDEXSEEK(m.lcValue,.F.,'temp','test')
INSERT INTO temp VALUES (m.lcValue)
This.Requery()
ENDIF
ENDPROC
ENDDEFINE

--
Christophe Steyaert
Int. Repair Services Zeebrugge
L. Blondeellaan 5
8380 Zeebrugge
tel : 050 54 20 27
fax : 050 54 79 84
"Stefan Wuebbe" <stefan.wuebbe@gmx.de> schreef in bericht
news:u4LJDOunIHA.2328@TK2MSFTNGP03.phx.gbl...
>
> "christophe" <nothingtosend@empty.com> schrieb im Newsbeitrag
> news:ORbPmjtnIHA.4196@TK2MSFTNGP04.phx.gbl...
>> Stefan,
>>
>> I have put this code in the combo.valid()
>>
>> IF .not. seek(this.DisplayValue,"rowsourcetable")
>> INSERT INTO "rowsourcetable" (klantnr) VALUES (this.displayvalue)
>> this.Requery()
>> ENDIF
>>
>> but still it is blanked when leaving the combobox.
>> Although the rowsource is correct.
>
> The example.prg below works for me, same for you?
> If so, can you modify it to match your requirements and make it
> reproduce the misbehaviour you observed?
>
>
> hth
> -Stefan
>
>
>
> *
> PUBLIC oform1
> oform1=NEWOBJECT("form1")
> oform1.Show()
> RETURN
>
> DEFINE CLASS form1 AS form
> ADD OBJECT combo1 AS combobox WITH ;
> RowSourceType = 3, ;
> RowSource = "select * from temp into cursor (sys(2015))", ;
> Height = 24, ;
> Left = 72, ;
> Top = 60, ;
> Width = 100
>
> ADD OBJECT text1 AS textbox WITH ;
> Height = 23, ;
> Left = 156, ;
> Top = 156, ;
> Width = 100, ;
> Value = 'focus dummy'
>
> PROCEDURE Load
> LOCAL lnSelect
> lnSelect = SELECT(0)
> CREATE CURSOR temp (test C(10))
> INDEX on test TAG test
> FOR i = 1 TO 3
> INSERT INTO temp VALUES (TRANSFORM(i))
> ENDFOR
> GO TOP
> SELECT (m.lnSelect)
> ENDPROC
>
> PROCEDURE combo1.Valid
> LOCAL lcValue
> lcValue = TRIM(This.DisplayValue)
> IF !EMPTY(m.lcValue) AND !INDEXSEEK(m.lcValue,.F.,'temp','test')
> INSERT INTO temp VALUES (m.lcValue)
> This.Requery()
> ENDIF
> ENDPROC
> ENDDEFINE
> *
>
>
>
> --
> |\_/| ------ ProLib - programmers liberty -----------------
> (.. ) Our MVPs and MCPs make the Fox run....
> - / See us at www.prolib.de or www.AFPages.de
> -----------------------------------------------------------
>



Re: combobox,rowsource,displayvalue,controlsource by Stefan

Stefan
Tue Apr 15 07:49:27 CDT 2008


"christophe" <nothingtosend@empty.com> schrieb im Newsbeitrag
news:ukNcrbunIHA.944@TK2MSFTNGP05.phx.gbl...
> Hi,
>
> I've marked with an ** which code i've added.
> Then you'll see the behaviour I don't want.
> I just add a combobox controlsource with a table.

I see, with a bound combo.ControlSource, try an additional line
in combo.Valid() (after the "Insert Into <rowSource>...") like:

This.Value = This.DisplayValue && or
This.ListIndex = This.ListCount


(BTW, the combo.BoundTo=.T. in your example might be
required with numeric BoundColumn values only.)



hth
-Stefan




--
|\_/| ------ ProLib - programmers liberty -----------------
(.. ) Our MVPs and MCPs make the Fox run....
- / See us at www.prolib.de or www.AFPages.de
-----------------------------------------------------------



Re: combobox,rowsource,displayvalue,controlsource by christophe

christophe
Tue Apr 15 10:14:27 CDT 2008

perfect.
thanks

Christophe

"Stefan Wuebbe" <stefan.wuebbe@gmx.de> schreef in bericht
news:OoBtmcvnIHA.5084@TK2MSFTNGP04.phx.gbl...
>
> "christophe" <nothingtosend@empty.com> schrieb im Newsbeitrag
> news:ukNcrbunIHA.944@TK2MSFTNGP05.phx.gbl...
>> Hi,
>>
>> I've marked with an ** which code i've added.
>> Then you'll see the behaviour I don't want.
>> I just add a combobox controlsource with a table.
>
> I see, with a bound combo.ControlSource, try an additional line
> in combo.Valid() (after the "Insert Into <rowSource>...") like:
>
> This.Value = This.DisplayValue && or
> This.ListIndex = This.ListCount
>
>
> (BTW, the combo.BoundTo=.T. in your example might be
> required with numeric BoundColumn values only.)
>
>
>
> hth
> -Stefan
>
>
>
>
> --
> |\_/| ------ ProLib - programmers liberty -----------------
> (.. ) Our MVPs and MCPs make the Fox run....
> - / See us at www.prolib.de or www.AFPages.de
> -----------------------------------------------------------
>