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!

checkbox ?

Status
Not open for further replies.

fluppe689

Programmer
Jul 11, 2008
75
BE
Hello Guys,

Something I did not have i my whole vfp live
I have cursor called tmp_gvert
It has been filled up

then is :
SELECT tmp_gvert
SET ORDER TO TAG vtnr
GO TOP
IF ! EMPTY(t_gem.vtnr)
LOOKUP(tmp_gvert.vtnr,;
t_gem.vtnr,;
tmp_gvert.vtnr,;
'vtnr')
WAIT WINDOW STR(tmp_gvert.vtnr)+Tmp_gvert.vtnaam
THISFORMSET.frmgem.pageframe1.page1.cb_vert.DISPLAYVALUE = tmp_gvert.vtnaam + " " + STR(tmp_gvert.vtnr,3,0)
THISFORMSET.frmgem.pageframe1.page1.cb_vert.VALUE = tmp_gvert.vtnaam + " " + STR(tmp_gvert.vtnr,3,0)
ENDIF

IN THE WAIT WINDOW EVERYTHIN OK
IN THE COMBOBOX EVERYTHING IS BLANK

WFG

FILIP
 
Filip,

not that it matters so much anymore, since it now works. Please consider:
<code>
Rowsource = tmp_gvert.vtnaam + " "+str(tmp_gvert.ntnr,3,0)
</code>
this will result in something like "Jansen 123"

resulting in an alias with at least 1 space, since tmp_gvert.vrnaam is not trimmed.

Maybe I dont understansd your problem, but for me an alias() cannot have >0 spaces.

Regards,

Jockey(2)
 
Olaf - this is one of those secrets. I'm pretty sure that a combo with RowSourceType = 2 will accept the same kind of RowSource as a combo with RowSourceType = 6. Somehow, it's smart enough to figure it out.

Tamar
 
Tamar,

but then that would be a fieldlist. Coma delimited. And a number - str(tmp_gvert.ntnr,3,0) - can't be a field name. This is not working out as rowsource no matter what rowsourcetype.

I think Filip has mixed that up with something else.

Bye, Olaf.
 
hello Olaf and Tamar,

This works fine, at least for the last 10 years. this my code.

in the load of the formset


CREATE CURSOR tmp_gvert;
( vtnr N(3,0),;
vtnaam C(30))
index on vtnr tag vtnr additive
INDEX on vtnaam TAG vtnaam additive

CREATE CURSOR tmp_gem;
( postnr c(10),;
gemeente c(30),;
land c(20),;
vtnr n(3,0),;
vtnaam c(30))
INDEX on postnr TAG postnr additive

CREATE CURSOR tmp_nvert;
( postnr c(10),;
gemeente c(30),;
keuze n(1))
INDEX on postnr TAG postnr additive

in the initialisation( i call it clearscreen)


SELECT tmp_gvert
SET ORDER TO tag vtnr
APPEND BLANK
replace tmp_gvert.vtnr WITH 0
replace tmp_gvert.vtnaam WITH ""
*
sql = "select * " + CHR(13) +;
"from " + m.y_db1 + "f_vert" + CHR(13) +;
"order by vtnr "
retcode = sqlexec(handle,sql,"t_vert")
IF retcode > 0
SELECT T_vert
GO top
COUNT TO m.i
IF m.i > 0
SELECT t_vert
GO top
SCAN
SELECT tmp_gvert
SET ORDER TO tag vtnr
APPEND BLANK
replace tmp_gvert.vtnr WITH t_vert.vtnr
replace tmp_gvert.vtnaam with t_vert.vtnaam
ENDSCAN
endif
ELSE
= AERROR(aErrorArray) && Data from most recent error
WAIT WINDOW STR(aErrorArray(1),8,0) + CHR(13) +;
aErrorArray(2) + CHR(13) +;
'02 SELECT F_VERT'
RETURN
ENDIF
*
SELECT tmp_gvert
SET ORDER TO TAG vtnr
GO TOP

and than in the read of the record
sql = "select * " + CHR(13) +;
"from " + m.y_db1 + "f_gemeente" + CHR(13) +;
"where f_gemeente.postnr = " +;
"'" + thisformset.frmgem.pageframe1.page1.tb_postnr.Value + "'" + CHR(13) +;
"order by postnr"
retcode = SQLEXEC(handle,sql,'t_gem')
IF retcode > 0
SELECT t_gem
GO top
COUNT TO m.i
IF m.i > 0
SELECT t_gem
GO top
thisformset.zzswexist = 1
thisformset.frmgem.pageframe1.page1.tb_gemeente.Value = t_gem.gemeente
thisformset.frmgem.pageframe1.page1.tb_land.Value = t_gem.land
SELECT tmp_gvert
SET ORDER TO TAG vtnr
GO TOP
IF ! EMPTY(t_gem.vtnr)
=LOOKUP(tmp_gvert.vtnr,;
t_gem.vtnr,;
tmp_gvert.vtnr,;
'vtnr')
THISFORMSET.frmgem.pageframe1.page1.cb_vert.displayVALUE = tmp_gvert.vtnaam + " " + str(tmp_gvert.vtnr,3,0)
THISFORMSET.frmgem.pageframe1.page1.cb_vert.VALUE = tmp_gvert.vtnaam + " " + STR(tmp_gvert.vtnr,3,0)
THISFORMSET.frmgem.pageframe1.page1.cb_vert.REFRESH
ENDIF
ELSE
thisformset.zzswexist = 0
thisformset.frmgem.pageframe1.page1.tb_gemeente.Value = '
thisformset.frmgem.pageframe1.page1.tb_land.Value = '
SELECT tmp_gvert
SET ORDER TO TAG vtnr
GO TOP
THISFORMSET.frmgem.pageframe1.page1.cb_vert.DISPLAYVALUE=tmp_gvert.vtnaam + " " + STR(tmp_gvert.vtnr,3,0)
THISFORMSET.frmgem.pageframe1.page1.cb_vert.VALUE=tmp_gvert.vtnaam + " " + STR(tmp_gvert.vtnr,3,0)
ENDIF
SELECT t_gem
use
THISFORMSET.tstbutton (0,1,;
0,0,;
1,thisformset.zzswexist,0,0,0)
THISFORMSET.frmgem.pageframe1.page1.tb_gemeente.SETFOCUS()
ELSE
= AERROR(aErrorArray) && Data from most recent error
WAIT WINDOW STR(aErrorArray(1),8,0) + CHR(13) +;
aErrorArray(2) + CHR(13) +;
'02 SELECT F_GEMEENTE'
RETURN
ENDIF

it didn't work at the first time because i forgot the clearscreen

wfg,

Filip
 
Sorry Guys,

I forgot the most importand i think,

In my form the properties are :

rowsource : tmp_gvert.vtnaam + " " + str(tmp_gvert.vtnr,3,0)
rowsourcetype : alias
style : dropdown list

wfg,

Filip
 
Without knowing the data in tmp_gvert.vtnaam it's impossible to see what you actually have as the rowsource in the end, but what can be seen is that you add " " and a number via str().

The only way this could work out is vfp is ignoring the second part of tmp_gvert.vtnaam + " " + str(tmp_gvert.vtnr,3,0)

What is the rowsourcetype as value? Alias stands for 2. Is it really 2?

Then the only hing that could make this work is vfp is taking tmp_gvert.vtnaam as the alias name, ignoring the rest of the rowsource.

Bye, Olaf.
 
This actually works:

Use browser In 0
_screen.AddObject("combo1","combobox")
_screen.combo1.style = 2
_screen.combo1.RowSource = "browser 123"
_screen.combo1.RowSourceType = 2

Foxpro is diplaying the browser dbf as combobox items, it's ignoring the 123. Still that is nonsense.

I stand corrected in that it is possible and does not lead to an error, but only in these aspects. It's nonsense to set such a rowsource, there is no alias "browser 123" and there can't be.

In consequence your code should work out the same way, if you only set the rowsource to tmp_gvert.vtnaam or even better ALLTRIM(tmp_gvert.vtnaam).

Bye, Olaf.
 
Hi Flip,

you state 'it has worked for me for 10 years' and I believe it, still the space in your rowsource bothers me and others. Would you be able to drop a screenprint of your combobox with the dropdown visible here? - unless of course it is sensible data.

Regards,

Jockey(2)
 
I just tested. Here's what I did.

1) Create a new form.
2) In Load, add this code:

CREATE CURSOR Junk (cFld C(3), nFld N(3))
INSERT INTO junk VALUES ("abc", 123)
INSERT INTO junk VALUES ("def", 456)
INSERT INTO junk VALUES ("ghi", 789)

3) Drop a combo on the form.
4) Set the combo's RowSourceType = 2-Alias.
5) Set the combo's RowSource = Junk.cFld + " " + trans(Junk.nFld)

Save and run the form and the combo contains exactly what I'd expect:

abc 123
def 456
ghi 789

Tamar
 
Hey Jockey,

how do i drop a screen drop here printscreen paste does'nt work

wfg,
Filip
 
Tamar,

thanks, but you're not setting RowSource = Junk.cFld + " " + trans(Junk.nFld) in code, do you? You're talking about writing Junk.cFld + " " + trans(Junk.nFld) into the rowsource property in the property window, true?

So indeed the rowsource is '(Junk.cFld + " " + trans(Junk.nFld))' and it will make the combobox evaluate the expression for every row.

If taking RowSource = Junk.cFld + " " + trans(Junk.nFld) literally you'd set it to "abc 123" or to "ghi 789" and the combo would display an alias abc or ghi.

The essence is the alias rowsourcetype is really not meant for this, using fields would at least give a hint you're meaning an expression with fields instead of an alias.

But more important I was thinking of code all the time while Filip and you are talking about the property window.

Bye, Olaf.
 
Flip,

No need, I have found the answer already.

Tamar,

indeed. It works foth for 2-Alias and 6-Fields.
Have learned something again today.

Regards,

Jockey(2)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top