Home > Archive > Programming with dBASE > February 2006 > Update Combobox









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Update Combobox
Thomas Preston

2006-02-10, 8:23 pm

Can someone tell me what I'm doing wrong please. After an append to the
rowset, I want the combobox to display the newly added company. But the
value of the combobox does no change...it stays on the first record.
Thanks - Tom

form.combobox1.dataSource = form.formsdatamodule1.cusmas1.rowset.fields
["COMPANY"]
form.formsdatamodule1.cusmas1.rowset.findkeynearest( "COMPANY = '" +
conamemv + "'" )

Thomas Preston

2006-02-10, 8:23 pm

In article <MPG. 1e56bc49518766109896
80@news.dbase.com>, tom-
nospam@sharedcs.com says...
> Can someone tell me what I'm doing wrong please. After an append to the
> rowset, I want the combobox to display the newly added company. But the
> value of the combobox does no change...it stays on the first record.
> Thanks - Tom
>
> form.combobox1.dataSource = form.formsdatamodule1.cusmas1.rowset.fields
> ["COMPANY"]
> form.formsdatamodule1.cusmas1.rowset.findkeynearest( "COMPANY = '" +
> conamemv + "'" )
>
>

BTW, conamemv contains the company name of the newly added record. Also,
findkeynearest() returns true indicating an exact match has been found.
Thanks again - Tom
Eric Logan

2006-02-10, 8:23 pm

Thomas:
You seem to be working with both the datasource and datalink of a combobox.
You can make a newly added value in the combobobox dataSOURCE field show up
as one of the choices in the combobox by nulling and restoring the
datasource like this:
fds = f.combobox1.datasource
f.combobox1.datasource = null
f.combobox1.datasource = fds
(If your datasource is the rowset returned by a 'select distinct' query, you
might have to requery first, then refresh the datasource. Try it.)
If the combobox is dataLINKed to a field, when you append a new row the
combobox should initially be blank until you enter or select a value in the
combobox. If you move to an existing row, the combobox should display the
current value of its datalinked field.
Hope this helps
E.L.

> BTW, conamemv contains the company name of the newly added record. Also,
> findkeynearest() returns true indicating an exact match has been found.
> Thanks again - Tom



Tom Preston

2006-02-11, 3:23 am

[This followup was posted to dbase.programming and a copy was sent to
the cited author.]

Thanks Eric. The combobox is dataSOURCEd to the "company" field in the
rowset.
1. Form 1 has the combobox listing all companies (company field is
indexed tag company)
2. When you click the button on Form 1 to add a record, Form 1 opens
Form 2 with "do form 2.wfm"
3. The entry takes place on Form 2
4. When the record is commited, a Public variable is set to the newly
added company name, then Form 2 closes & returns focus to Form 1
5. At this point, I want the rowset to be positioned on the newly added
record and, therefore, the combobox to be displaying the company name of
the newly added record. To accomplish this, I am reaffirming the
datasource and then using findkeynearest() to navigate to the newly
added record.

The problem is that I am getting VERY strange behavior from the
combobox. findkeynearest() returns "true" every time, but the combobox
value does not change...that is unless you enter the letter "D" as the
newly added company name. Then the combobox value changed to D.

I'm sure this is a "Tom" error...not a dBASE bug, but it's got me
stumped. Help...please.

Tom

In article <4szlkUqLGHA.1152@news-server>, jelogan@pcweb.net says...
> Thomas:
> You seem to be working with both the datasource and datalink of a combobox.
> You can make a newly added value in the combobobox dataSOURCE field show up
> as one of the choices in the combobox by nulling and restoring the
> datasource like this:
> fds = f.combobox1.datasource
> f.combobox1.datasource = null
> f.combobox1.datasource = fds
> (If your datasource is the rowset returned by a 'select distinct' query, you
> might have to requery first, then refresh the datasource. Try it.)
> If the combobox is dataLINKed to a field, when you append a new row the
> combobox should initially be blank until you enter or select a value in the
> combobox. If you move to an existing row, the combobox should display the
> current value of its datalinked field.
> Hope this helps
> E.L.
>
>
>
>

Michael Nuwer [dBVIPS]

2006-02-11, 11:23 am

Thomas Preston wrote:
> Can someone tell me what I'm doing wrong please. After an append to the
> rowset, I want the combobox to display the newly added company. But the
> value of the combobox does no change...it stays on the first record.
> Thanks - Tom
>
> form.combobox1.dataSource = form.formsdatamodule1.cusmas1.rowset.fields
> ["COMPANY"]
> form.formsdatamodule1.cusmas1.rowset.findkeynearest( "COMPANY = '" +
> conamemv + "'" )
>


First: FindKeyNearest() is not looking for a SQL string; It is looking
for an index key. But this change will not solve your problem.

.findkeynearest( conamemv )


Second: Could you simply set the value property of the combobox and let
dbase do move the row pointer internally:

form.combobox1.dataSource = ;
form.formsdatamodule1.cusmas1.rowset.fields["COMPANY"]
form.combobox1.value=conamemv
Tom Preston

2006-02-11, 1:23 pm

In article <KlZgwNyLGHA.1152@news-server>,
nuwermj@nospam.please.yahoo.com says...
> Thomas Preston wrote:
>
> First: FindKeyNearest() is not looking for a SQL string; It is looking
> for an index key. But this change will not solve your problem.
>
> .findkeynearest( conamemv )


Yes, it did solve the problem! It goes 180 degrees against what I
"thought" I knew about dBASE...I am quite rusty...but it worked.

Thank you very much for taking the time to help. Glad to see dBVIPS are
still around when needed.

Thanks Again - Tom
Michael Nuwer [dBVIPS]

2006-02-11, 8:23 pm

Tom Preston wrote:

>
> Yes, it did solve the problem! It goes 180 degrees against what I
> "thought" I knew about dBASE...I am quite rusty...but it worked.


Thanks for the success report.

>
> Thank you very much for taking the time to help. Glad to see dBVIPS are
> still around when needed.


I'm glade I could help.
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com