On 07/16/2010 09:23 PM, Paul McNett wrote:
> On 7/16/10 5:22 PM, Jeff Johnson wrote:
>    
>> When running the application I have a form open which has listboxes
>>      
>>>> which are populated by fields in another table.  If I open up one of the
>>>> tables and add a record, what is the best way to update the choices in
>>>> the listbox on the main form?  I am guessing it is requery, but where
>>>> would be the best place to call it?
>>>>
>>>>          
>>> Whereever/whenever you want to requery for updated data. Where or when is 
>>> this?
>>>        
>    
>> I have the listbox on a form called policies.  The listbox contains
>> agents.  If I open up the agents form and add agents they don't update
>> the choices in the policies listbox.  So I need to requery the listbox
>> at some point.  It's not obvious to me where to do that.
>>      
> Ok so you have 2 forms: frmPolicies and frmAgents. frmPolicies has a listbox 
> of
> agents (lstAgents). You go and add an agent in frmAgents, and save, but 
> lstAgents
> isn't updated automatically.
>
> How about, in frmPolicies:
>
> class FrmPolicies(dabo.ui.dForm):
>     ...
>     def afterInit(self):
>       self.bind(dabo.dEvents.Activate, self.onActivate)
>       ...
>
>     def onActivate(self, evt):
>       print "form activate"
>       self.refreshAgents()
>
>     def refreshAgents(self):
>       bizAgents = self.getBizobj("agents")
>       bizAgents.requery()
>       dsAgents = bizAgents.getDataSet(flds=("id", "name"))
>       lstAgents = self.lstAgents  ## ('cuz you named it's RegID that way)
>       lstAgents.Choices = [rec["name"] for rec in dsAgents]
>       lstAgents.Keys = [rec["id"] for rec in dsAgents]
>
> Now, when the form is activated, lstAgents is populated with the current list 
> of
> agents. Note the code above is untested.
>
> Paul
>    File "/home/jeff/development/pythonprojects/jm/ui/FrmPolicies.py", line 
> 31, in afterInit
>    
     self.bind(dabo.dEvents.Activate, self.onActivate)
AttributeError: 'FrmPolicies' object has no attribute 'bind'

bind did not work, Paul

-- 
Jeff

-------------------

Jeff Johnson
[email protected]



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[email protected]

Reply via email to