Dirk,
That works great thank you
"Dirk Goldgar" wrote:
> "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)
>
>


|