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!

why update of rowsource is not displayed in combobox

Status
Not open for further replies.

Nifrabar

Programmer
Mar 16, 2003
1,343
NL
Hi!
Next scenario:
-vfp9
-form with pageframe
-dataenvironment with myTable1 myTable2 myTable3 these are all same table.
-on page2 of pageframe :combobox1 with rowsource = table1.field1; controlsource is formproperty aa
-on page2 of pageframe :combobox2 with rowsource = table2.field1; controlsource is formproperty bb
-on page3 of pageframe textbox + cmd. these are used to add data to table3

When a record is added to table3 I can't see the update in table1 and/or 2 (list of combobox don't show up new record)

I tried setting rowsource to "" and than reset to original rowsource.

What do I oversee?
If form is closed and instanciated again than new record is available in both comboboxes.

TIA
-Bart
 
in addition: no buffering active for tables and form
 
Try calling the Requery method for the two combos after you add records.

Tamar
 
Tamar,
I tried but without result.
I included the thisform.refresh as well after the requery.
-Bart
 
This still looks like buffered data. If you don't set form.buffermode and neither the datenvironment nor table buffermodeoverride, you can still have cursorsetprop of the buffermode, eg CursorSetProp("Buffering",x,0) set's buffermode for workarea 0, which effectively set buffermode for all future tables opened in this datasession.

Check CursorGetProp("Buffering","table1") /CursorGetProp("Buffering","table2") and of course also CursorGetProp("Buffering","table3") at the moment you save a new record. Check if DBF("table1/2/3") all really point to the exact same file.

Bye, Olaf.
 
Bart,

myTable1 myTable2 myTable3 these are all same table. 3 times same table under a different name??

how are formproperties "aa" and "bb" related to table3 ?


Groet,

Jockey(2)

 
Jockey, the form properties aa and bb are controlsources to the comboboxes, Bart stated that in the initial post. What more do you need to know? It won't matter what field the comboboxes are bound to, the controlsource merely can set the active record and stores the choice, but when you expand the item list, the controlsource doesn't filter what you see, you see all rows of the rowsource. And if that's three aliases of the same table, the same items should appear.

I'd say requery is necessary anyway and buffering is o hurdle, new records just then need to be stored by tableupdate(). Not buffering of course makes adding records a more direct change to the underlying DBF, but the comboboxes will need to requery, also with rowsourcetype table or alias or fields.

Also using three aliases for the same table gives three independent record pointers and is the correct solution in itself, to feed comboboxes with the same data.

The question about the buffering status is still open, Bart, but also how you use textbox+cmd to save new records into the table. If you bind the table3 to the textbox, you can navigate records and change them, but won't add new records. With an unbound textbox and an INSERT or APPEND+REPLACE in cmd you can of course add new records, which is, what I assume you do. For a more independent check add a new debug button which has USE table3.dbf ALIAS check IN 0 AGAIN / SELECT check / BROWSE. And then see, if a newly added record really arrives in the DBF.

Bye, Olaf.
 
Olaf,
I am still puzzled, what is the final goal in this architecture? If you have myTable as table1 and you have table1.field1 as rowsource of combo1 and if you have myTable as table2 and you have table2.field1 as rowsource of combo2 both comboxes will show same content.
Now if you set thisform.myProperty1 = table1.field2 as controlsource and if you set thisform.myProperty2 to table1.field2 as controlsource there is still no 'relation' to the alias table3 which is in effect myTable
If you update table3 than the other aliases of myTable will not update just like that.
It could be I am mistaken, I should have to test this and even if it 'works' I dont understand why one would bother to construct this.
I am studious to learn what is going on here.
Regards,
Jockey(2)
 
If you have different aliases for the same table and different controlsources, the two comboboxes can show different rows, because you have two record pointers into the table. Because the recordpointer is for the workarea, not for the table.

So in short: USE sometable in 0 alias sometable1, USE sometable in 0 alias sometable2, GOTO 2 in sometable1, GOTO 5 in sometable2.

Now imagine you have a list of product categories and want to allow the user picking two from the same list. Then two comboboxes with the same table as rowsource would offer that, if you open the table twice with different aliases. That architecture is ok.

Bye, Olaf.
 
Olaf,

That makes sense. So combo1 and combo2 (table1 and table2) are lookup comboboxes - and also it does not make sense as one is fully capable of using one(1) cursor for n different comboboxes and feed all combobox with same recordsource and each combobox with a different field from that recourdsource as rowsource.
Seems to me much easier to maintain and to program - which could be personal style of programming.
Anyhow Bart should construct some procedure for table3 to update myTable and should certainly take care of the Buffering of all three aliases to repopulate the comboboxes for which requery() should do the job.

Thanks for replying,

Bye

Jockey(2)
 
Hi!
To be more specific about what I am trying to achieve:
In my app users can print two different sizes of labels from a data form.
Upto now the size of those labels was hardcoded.
In that app there is an 'settings cq options' form.
In that form users can customize the app. So also it is possible to select two different label-sizes.
Here it comes that in the dataenvironment I put the tabel with label-definitions twice.
I know that VFP usualy creates new labels using the registry but I feel more comfortable using a table for that.
In an INI-file I do store the id's of both of the preferred labels. When using this setting-form I put those in a formproperty. That property than acts as control-source of the comboboxes mentioned in previous posts. Users also ask to be able to create a label of their own size. That's also managed on this form. Meanwhile I have hardcoded default-values which might be recalled.

And here's another strange effect. When I 'reset one of the labelsizes I don't get the required label displayed in the combobox.
I'm struggling a bit how to set the bound property in here.

I feel stupid as I have changed that many small issues with as a result that the original problem: not having update of table3 in both comboboxes is gone....

But some other small problems came in place. 1st of all I should like to be informed about setting of the bound-property.
BTW, I also created an index for the table which is set in dataenvironment as well. Currently all is still without buffering.

-Bart
 
Hi,
Bart VFP by default gives you a label.dbf in the home() directory. Here you can find a huge number of labels, I dont believe there are so many more labelsizes possible or it must be that you are not using 'address'-labels but labels with very user specific content like e.g. a label to be sticked on a box with its contents and a Bar- or QR-code plus a firm-logo a.s.o.
So to KIS (Keep it Simple) use that label.dbf and have the users select from that. You can list the content from 1 combobox and built your report/label frm from that. If that is not enough for you, you can consider to export your data to a Word-Table and open up MS-Word now users can play around with labels as they like.

Your architecture as you described here above, with 3 combo-boxes and a ini-file (???) would never ever have my preference.

And lastly, have you tried to make use of the requery() method?

If you like I could mail you a form with 2 comboboxes and a button which populates the two boxes with a new record and shows in the comboboxes this new record as well.

Unfortunately I am not familiar how to upload a zip file to this forum, maybe someone could tell me than I can pass it here.

Groet,

Jockey(2)
 
Jockey,

I actually havent tested, but the same alias on two comboboxes wouldn't work well, if the user shoul dbe allowed two choices. You might visually still see the first choice, when making a second, but there is only one record pointer in one alias. The best solution might really be a multiselect listbox instead. But limiting that to two choices also is a job to be done.

Bart,

wenn you set the formproperties aa/bb to new values a refresh of the form/comboboxes should let them show the right records, nothing is needed. You don't reset the boundto property, nor boundcolumn, nor value. Like the change of a property or field a textbox is bound to via controlsource also let's the new value appear after a refresh.

If that effect doesn't happen, you haven' set up boundto and boundcolumn correctly. You say you want the combobox bound to the Id field. Looking into the labels.dbf I see LABELLLYT in all records, so this isn't the unique id of the labels.dbf, you have to add a unique column, indeed. There is none. The Chkval seems so, but surely is something like a checksum and could also be double. The reidentifying field is actually the name. so why not make it easy and bind to the name field?

Bye, Olaf.
 
Hi!
I use the updated labels.dbf. i.e. I added a column with normal ID-values (integers). Also I figured out the values in the memo and converted them to normal fields.

Jockey, How would you store preferred choices of labels? You used to use a table for that? For me an ini-file works-out fine.

Olaf, having two comboboxes for the preferred labels I do have two formproperties. (in fact its a one-dimension array).
These are the values which are bound to the controlsource of the comboboxes.

As in this phase my code is a bit spaghetti I have redo some coding to make tracing better possible.
I will return with some code maybe later if still I don't reach my goal.

-Bart
 
So, do you really set combo1.controlsource = "thisform.array[1]" and combo2.controlsource = "thisform.array[2]"? I fear that won't work.

Bye, Olaf.
 
Olaf, indeed:
cboEtiket1.controlsource = thisform.aetiket[1]
Why won't this work?
-Bart
 
Bart,
you cannot set the content of an array to your controlsource.

You have to set thisForm.combo1.controlSource = MyTable and thisForm.combo1.rowsource = myTable.myField(n)

Bart, save the preferences in the same table which you have constructed with the content of Labels.dbf, just add one field : lPrefer (L) and update with .T.

Now you can even make an index on lPrefer to speed up things and or to organize these records on top.

Ini files = plain text files are for storing and reading global user defined values. I would never use these kind of files for datahandling but again that is personal architecture.

Again: how do I upload a zip file to this message?

Groet,

Jockey(2)
 
Controlsource can be a field, variable or property. I haven't tested, but I doubt an array element will go. Now I'll try...
..okay, it works, yes. An array element compares to a single variable. It doesn't seem straight forward to me, why you use a two element array, but it works. So how do you set up your combobox overall?

controlsource
rowsource
rowsourcetype
boundcolumn
boundto

Bye, Olaf.
 
@Jockey,

to attach something you can only refer to a file in the web, tek-tips doesn't allow to attach files. But you can get free webspace easy enough: Dropbox, Google Drive, SkyDrive... Upload there and share via the link to a file. Any three of them allow a public section/folder and have a feature to create a link you can use either in your posting text or in the Attachment box below the message textarea.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top