Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Keep Drop Down List Boxes in Sync
Message
From
03/01/2001 07:20:16
 
 
To
03/01/2001 07:08:57
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00458752
Message ID:
00458841
Views:
22
Hi!

See my corrections and comments below, hope this helps.

>Hi Vlad
>
>THis is the code that activates the page.
>
>* iKey holds the parameter of the of the p-view JobView
>ThisForm.iKey = INT(VAL(SUBSTR(Node.Key, 5)))
>REQUERY("JobView")
>SELECT "JobView"
>ThisForm.PageFrame1.ActivePage = 4
>ThisForm.PageFrame1.Page4.Refresh()
>
>
>In the .Activate of the page the following code populates the comboboxes
>
>WITH This  && Form.PageFrame1.Page4
>  * Customer Listbox
>  SELECT ;
>    Customer.CustName, Customer.CustId;
>    FROM ShopTrack!Customer;
>    ORDER BY Customer.CustName;
>    INTO ARRAY .cboCustomer.laData
>  IF _TALLY = 0
>    DIMENSION .cboCustomer.laData[1,1]
>    STORE "No Customers" TO .cboCustomer.laData
>  ENDIF

* following is required
.cboCustomer.Requery()
.cboCustomer.Refresh()

>  * Contact Listbox
>  SELECT ;
>    ALLTRIM(Contacts.LName) + ', ' + ALLTRIM(Contacts.FName) AS ContName,;
>    Contacts.ContId;
>    FROM ShopTrack!Contacts;
>    WHERE Contacts.CustId = INT(VAL(.cboCustomer.List(.cboCustomer.ListIndex, 2)));

Here you use ListIndex that is zero or invalid just because you did not refreshed Customer combobox. Combobox based on array requires 'Requery' and 'Refresh' after changes in the array.

>    ORDER BY ContName;
>    INTO ARRAY .cboContact.laData
>  IF _TALLY = 0
>    DIMENSION .cboContact.laData[1,1]
>    STORE "No Contacts" TO .cboContact.laData
>  ENDIF

Here requery and refresh recommended too.

>ENDWITH
>
>
>Valid empty on both
>InteractiveChange  Customer cbo
>WITH This.Parent
>  lnCustId = INT(VAL(This.List(This.ListIndex, 2)))
>  DIMENSION .cboContact.laData[1,1]
>  SELECT ;
>    ALLTRIM(Contacts.LName) + ', ' + ALLTRIM(Contacts.FName) AS ContName,;
>    Contacts.ContId;
>    FROM ShopTrack!Contacts;
>    WHERE Contacts.CustId = lnCustId;
>    ORDER BY ContName;
>    INTO ARRAY .cboContact.laData
>  IF _TALLY = 0
>    STORE "No Contacts" TO .cboContact.laData
>  ENDIF
>  .cboContact.Requery()
>  .cboContact.ListIndex = 1
>ENDWITH
>
>BountColumn 2 on both
>BoundTo .t. on both
>ControlSource jobview.custid and jobview.contid
>RowSourceType array
>RowSource (or code that fills it) see above
>
>
>
>Thanks so much for your help
>
>>Hi!
>>
>>Hmm, it seems you expect that record pointer in the view changed when you select record in the first (company) combobox. Than, if second combobox tied to view using control source, you just need to call refresh method of the second combobox after record pointer changed. Better do this in the Valid event of the first combobox - for comboboxes Valid seems called each time value changed.
>>
>>It will be also much better if you tell exactly following properties and methods of both comboboxes:
>>
>>Valid
>>InteractiveChange
>>BountColumn
>>BoundTo
>>ControlSource
>>RowSourceType
>>RowSource (or code that fills it)
>>
>>etc.
>>
>>This way problem could be figured out exactly.
>>
>>>I have two dropdown list boxes on a pageframe that is bound to a view. The first box contains two columns company name and company id, it's bound to the id. The second box contains contact name and contact id for the current company, it's bound to the contact id of the view. The contact drop down list box does not stay in sync when I select another company from the treeview. When I select the second item for the same company the contact catches up. I am populating the list boxes in the activate of the page. The p-view contains company id and contact id and part info. I must be missing something ...
>>>
>>>Thanks
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform