469,934 Members | 1,873 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,934 developers. It's quick & easy.

Continuous subform -LOOP

Hello everyone! Using A2K

i have a form(a) with a subform(b) and within the subform there is a
continuous subform(c).

in the subform (b) there is a command button used to call a public function
(CubiertaCalculacion) which holds a calculation for form (c)(grandchild)
..............The calculation stores the result on a field (Total) on the
continuous subform(c) (grandchild) based on another two fields on the same
subform .............e.g. field1 (Quantity) Field2(Price)
Total(Field1*Field2) by the way this a sample calculation as the real one is
very complex and I cannot place it on the query(qryCubierta) the record
source of the continuous subform(c).

The calculation on the public function works fine, my problem is that when I
run the code from the subform(b) it only affect the first record showing on
subform(c) and I want the code to calculate the TOTAL for every record
showing on the continuous subform(c).

This ist the code behind the command button;

Private Sub Command48_Click()
Dim mydb As DAO.Database
Dim rst As DAO.Recordset
Set mydb = CurrentDb()
Set rst = mydb.OpenRecordset("qryCubierta", DB_OPEN_DYNASET)

Do Until rst.EOF
Call CubiertaCalculacion
End Sub

I have placed the command button on the detail section of the continuous
subform(c) and it works fine, by it would implicate the user pressing the
button for every record showing to get a result, and I would prefer it as
explained above.

If any of you know what is wrong with my code, I would appreciate your
suggestion or working example.

Nov 13 '05 #1
1 2563
Hi gavo,

It's pretty hard to tell what's going on without seeing
CubiertaCalculacion, but it appears that your recordset is not being
used properly. You call CubiertaCalculacion in exactly the same way for
every record in the recordset. You may need to pass some information
from rst to CubiertaCalculacion so it can process a different record
each time.

Other options:
- Create the recordset in CubiertaCalculacion, and loop to do the
calculations on each record.
- Build a function that does the calculation for one record, and call
it from a query. For example, use a query qryC for the RecordSource of
subform (c), and include something like
CubiertaCalculacion(Field1,Field2,Field3) as one of the fields.


Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Karl Roes | last post: by
8 posts views Thread by Steffen Beck | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.