Talk About Network

Google





Software > Access Forms > Re: clear list ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 12 of 14 Topic 46474 of 46786
Post > Topic >>

Re: clear list box

by "Dirk Goldgar" <dg@[EMAIL PROTECTED] > Dec 2, 2008 at 11:45 PM

"raviyah" <raviyah@[EMAIL PROTECTED]
> wrote in message 
news:432FE438-FC9B-4DD2-AEA9-CD332A2CBD5B@[EMAIL PROTECTED]
> Dirk,
>
> If there is another way to send the code, let me know.
> There are a number of combo boxes to choose from and fill in
lboModPartMod
> That query is working fine.
> lboModPartModNum is listbox1 and lboModPartLoc is listbox2. lboModEff is
> also a listbox2
>
> cmd are command buttons, cbo is a combo box and lbo are listboxes.
> There is just the one form
>
> here is the code from the VBE:
>
> Option Compare Database
>
> Private Sub cboModPartLoc_AfterUpdate()
> Me.lboModPartMod.Requery
> End Sub
>
> Private Sub cboModPartNum_AfterUpdate()
> Me.lboModPartMod.Requery
> End Sub
>
> Private Sub cmdModPartLocDelete_Click()
> Me.cboModPartLoc = ""
> End Sub
>
> Private Sub cmdModPartNumDelete_Click()
> Me.cboModPartNum.Value = ""
> End Sub
>
> Private Sub lboModPartMod_AfterUpdate()
> Me.lboModPartLoc.RowSource = "SELECT qryModPartLoc.ModPartNum,
> qryModPartLoc.Loc1, qryModPartLoc.Loc2, qryModPartLoc.Loc3,
> qryModPartLoc.Loc4 FROM qryModPartLoc WHERE
>
(((qryModPartLoc.ModPartModNum)=forms!frmModPartsSearch!lboModPartMod.value));

> "
> Me.lboModPartLoc.Requery
> Me.lboModEff.RowSource = "qryModNumEff"
> Me.lboModEff.Requery
> End Sub
>
> Private Sub CmdSearch_Click()
> Dim varItem As Variant
> For Each varItem In lboModPartMod.ItemsSelected
>   lboModPartMod.Selected(varItem) = False
> Next varItem
> Me.lboModPartMod.Requery
> 'Me.lboModPartLoc = Null
> Me.lboModPartLoc.RowSource = ""
> Me.lboModPartLoc.Requery
> 'Me.lboModEff = Null
> Me.lboModEff.RowSource = ""
> Me.lboModEff.Requery
> End Sub


Hmm, that code does not conform to what I suggested that you do.  Let me 
state my understanding of the situation, for you to check and correct or 
confirm:

+ cboModPartNum and cboModPartLoc are combo boxes.

+ lboModPartMod is a list box whose rowsource is dependent on the values 
selected in cboModPartNum and cboModPartLoc.

+ lboModPartLoc and lboModEff are list boxes whose rowsources are, or
should 
be, dependend on the value selected in lboModPartMod.

+ There is code currently in the AfterUpdate events of the two combo boxes

to requery lboModPartLoc so that its list correctly reflects the the 
selected values in the combo boxes.  This works.

+ However, the other list boxes, lboModPartLoc and lboModEff, don't clear 
when you do this.  Instead, they keep the same lists they had when you
last 
selected an item in lboModPartMod.  What you want is for these list boxes
to 
clear when you change the selected values in the combo boxes, until you
next 
select an item in lboModPartMod.

Assuming that's correct, change your code to the following:

'------ start of code (modified procedures only) -----
Private Sub cboModPartLoc_AfterUpdate()
    Me.lboModPartMod.Requery
    Me.lboModPartMod = Null
    Me.lboModPartLoc.Requery
    Me.lboModEff.Requery
End Sub

Private Sub cboModPartNum_AfterUpdate()
    Me.lboModPartMod.Requery
    Me.lboModPartMod = Null
    Me.lboModPartLoc.Requery
    Me.lboModEff.Requery
End Sub

Private Sub lboModPartMod_AfterUpdate()
    Me.lboModPartLoc.Requery
    Me.lboModEff.Requery
End Sub

'------ end of code -----

That assumes that you have set up the list boxes at design time with 
rowsources that refer to the appropriate controls on the form for
criteria.

I don't know what your CmdSearch button is for -- there was no mention of
it 
in your previous posts, but it looks like you tried some of the code I 
suggested there, though that was not what I intended.

By the way, there is never any need to explicitly requery a combo or list 
box after you set its RowSource property.  Setting the RowSource property 
automatically forces a requery.

-- 
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 




 14 Posts in Topic:
clear list box
=?Utf-8?B?cmF2aXlhaA==?=   2008-12-01 15:53:01 
Re: clear list box
"Dirk Goldgar"   2008-12-01 19:07:45 
Re: clear list box
=?Utf-8?B?cmF2aXlhaA==?=   2008-12-01 16:19:03 
Re: clear list box
"Dirk Goldgar"   2008-12-01 19:37:21 
Re: clear list box
=?Utf-8?B?cmF2aXlhaA==?=   2008-12-02 07:11:01 
Re: clear list box
"Dirk Goldgar"   2008-12-02 10:48:02 
Re: clear list box
=?Utf-8?B?cmF2aXlhaA==?=   2008-12-02 07:21:01 
Re: clear list box
"Dirk Goldgar"   2008-12-02 10:50:56 
Re: clear list box
=?Utf-8?B?cmF2aXlhaA==?=   2008-12-02 08:06:17 
Re: clear list box
"Dirk Goldgar"   2008-12-02 11:11:30 
Re: clear list box
=?Utf-8?B?cmF2aXlhaA==?=   2008-12-02 09:32:01 
Re: clear list box
"Dirk Goldgar"   2008-12-02 23:45:06 
Re: clear list box
=?Utf-8?B?cmF2aXlhaA==?=   2008-12-03 11:24:11 
Re: clear list box
fredg <fgutkind@[EMAIL  2008-12-01 16:11:12 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Fri Jan 9 15:36:39 PST 2009.