[AccessD] Using the recordset of a list control

philippe pons phpons at gmail.com
Wed Aug 22 14:44:51 CDT 2007


Mark, you are correct!

When I select a new choice in the cbo, the code build a new sql string with
the correct WHERE criteria according the selection, passes this string to
the rowsource of the listbox, and makes a list box requery.
Then the listbox shows the correct information.
BUT, after having selected a new choice with the cbo, then the recordset no
longer exits, and I can't sum the values.

Doing that would have avoid querying the database, reducing network traffic!
But it doesn't work!!

Never mind, I will query the datebase to make my sums!

Thanks again,

Philippe


2007/8/22, Mark A Matte <markamatte at hotmail.com>:
>
> ahhh...we might be getting somewhere...
>
> Please correct me if I am wrong.
>
> You have a combo box, a list box, and a text box.
>
> A selection is made in the combo...that changes the row source of the list
> box...and the text box is supposed to sum the values in the list box?
>
> If this is true... (anyone else please chime in)... if you change a
> rowsource property via code...and don't save...and try to reference said
> property...will you get the changed or original via code?
>
> Instead of referencing the listbox.rowsource could you have the text box
> loop through the SQL statement instead ( I am assuming you have that SQL
> in
> code since the combo changes the SQL in the listbox.rowsource)?
>
> Am I close?
>
> Thanks,
>
> Mark A. Matte
>
> >From: "philippe pons" <phpons at gmail.com>
> >Reply-To: Access Developers discussion and problem
> >solving<accessd at databaseadvisors.com>
> >To: "Access Developers discussion and problem
> >solving"<accessd at databaseadvisors.com>
> >Subject: Re: [AccessD] Using the recordset of a list control
> >Date: Wed, 22 Aug 2007 20:49:45 +0200
> >
> >Mark,
> >
> >Yes, the rowsource is a sql (sql="select bla, bla..":
> >Me.lstListe.RowSource=sql), and on the form I have a combo box that will
> >update the list rowsource according the selection made.
> >Fields(1) and Field(2) are normally not Null.
> >Another fact: befor doing the calculation, I tried to requery the list,
> to
> >ensure th existence of a recordset, but it seems to be unefficient!
> >
> >Thanks for your help.
> >
> >2007/8/22, Mark A Matte <markamatte at hotmail.com>:
> > >
> > > Philippe,
> > >
> > > No problem on the verbage...I was just making sure I understood. In
> this
> > > sense...scan=loop.
> > >
> > >
> > > First question...what is the Rowsource on the listbox and does it
> >change?
> > >
> > > Second Question...where you use .Fields(2) and .Fields(3)...can these
> >ever
> > > be null?
> > >
> > > Thanks,
> > >
> > > Mark A. Matte
> > >
> > >
> > > >From: "philippe pons" <phpons at gmail.com>
> > > >Reply-To: Access Developers discussion and problem
> > > >solving<accessd at databaseadvisors.com>
> > > >To: accessd at databaseadvisors.com
> > > >Subject: Re: [AccessD] Using the recordset of a list control
> > > >Date: Wed, 22 Aug 2007 19:40:11 +0200
> > > >
> > > >I say scan because I missed the verb you use to indicate you are
> >"walking
> > > >through" the collection of rows of a recordset. I do something like
> >that
> > > >(basic!):
> > > >     Me.lstListe.Recordset.MoveFirst
> > > >     ' if the recorset does'nt exist, get out!
> > > >     If Err.Number <> 0 Then
> > > >         Err.Clear
> > > >         Exit Sub
> > > >     End If
> > > >     Do While Not Me.lstListe.Recordset.EOF
> > > >         sngTotPourc = sngTotPourc + Left(
> Me.lstListe.Recordset.Fields
> > > (2),
> > > >Len(Me.lstListe.Recordset.Fields(2)) - 1) / 100
> > > >         curTotMontantsPre = curTotMontantsPre +
> > > >Me.lstListe.Recordset.Fields
> > > >(3)
> > > >         Me.lstListe.Recordset.MoveNext
> > > >     Loop
> > > >I have to check the existence of the recordset, because sometimes,
> > > although
> > > >the list is there on the form, it  does not exist, giving then an
> >error!
> > > >
> > > >2007/8/22, philippe pons <phpons at gmail.com>:
> > > > >
> > > > > Hi all,
> > > > >
> > > > > I have a form with a list control.
> > > > > The list displays quantities and amount.
> > > > > Under the list, I have some text box that should display the total
> >of
> > > > > these quantities and amount.
> > > > >
> > > > > What I do is to use the recordset of the list, to scan each of the
> > > >record
> > > > > and do the sum I need.
> > > > >
> > > > > The problem is that this recordset does'nt seem to be reliable.
> > > > > Sometimes it does'nt exist anymore, sometimes it has 250 rows
> >instead
> > > of
> > > > > just 5 to 10.
> > > > > The calcultaion is ok only the first time i do it, and then it's
> >not!
> > > > >
> > > > > Did you already get into these kinds of troubles?
> > > > > What am I doing wroung?
> > > > >
> > > > > TIA,
> > > > > Philippe
> > > > >
> > > >--
> > > >AccessD mailing list
> > > >AccessD at databaseadvisors.com
> > > >http://databaseadvisors.com/mailman/listinfo/accessd
> > > >Website: http://www.databaseadvisors.com
> > >
> > > _________________________________________________________________
> > > Puzzles, trivia teasers, word scrambles and more. Play for your chance
> >to
> > > win! http://club.live.com/home.aspx?icid=CLUB_hotmailtextlink
> > >
> > > --
> > > AccessD mailing list
> > > AccessD at databaseadvisors.com
> > > http://databaseadvisors.com/mailman/listinfo/accessd
> > > Website: http://www.databaseadvisors.com
> > >
> >--
> >AccessD mailing list
> >AccessD at databaseadvisors.com
> >http://databaseadvisors.com/mailman/listinfo/accessd
> >Website: http://www.databaseadvisors.com
>
> _________________________________________________________________
> Booking a flight? Know when to buy with airfare predictions on MSN Travel.
> http://travel.msn.com/Articles/aboutfarecast.aspx&ocid=T001MSN25A07001
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>



More information about the AccessD mailing list