# Thread: Continous form (Access 2000)

1. ## Continous form (Access 2000)

I have a continous form with different rows.I want to perform a simple calculation of substraction,but it substracts only the first row.I want to substract all the rows however, since al these rows belong to one and the same order.
For example:
Me!branch0 = Me!Branch0 - Me!cartons
only the first row is substracted.
Shall i send a small example, or the problem is known to you ?

2. ## Re: Continous form (Access 2000)

Could you supply an example? Without seeing your database (or having much experience with continuous forms) I would advise running a select query with a calculated field and linking to it, but that probably isn't the most programatically acceptable solution.

3. ## Re: Continous form (Access 2000)

If you are trying to do this in a textbox in the footer, you need to use <code>Sum([Branch0]) - Sum([Cartons])</code>

4. ## Re: Continous form (Access 2000)

I answered your question about summing in another post. I wanted to point out that your proposed formula will cause a circular reference, so be careful. Me!branch0 = Me!Branch0 - Me!cartons would create an endless loop and eventually crash, so instead, you get a circular reference error. Explain what you are trying to do so we can propose a better solution.

5. ## Re: Continous form (Access 2000)

Thank you for the reply.I am sending the attachment with an example of my problem. By clicking the command I want the calculation to run over all the rows and not only on the first row.My code in the command is :
Private Sub Command20_Click()
Me!branch0 = Me!branch0 - Me!cartons
End Sub
In my example :
The third product has branch0 = 30 and cartons = 1
The first product has branch = 10 and cartons = 1
On clicking the command, I get the calculation only on the first row :The branch0 becomes 29 but not on the subsequent rows.They remain the same, and I want with the click to carry out the caclulations for all the rows. I have curtailed a lot in my attachment.Otherwise it is more complicated.So for example, I cannot use the simple solution to carry out the calulations on the query, I have to do them on the form.

6. ## Re: Continous form (Access 2000)

Your code will only act on the currently selected record (not necessarily the first one). If you want it to act on all records, you must execute an update query. For example:

Private Sub Command20_Click()
Dim strSQL As String
strSQL = "UPDATE qryOrderDetails SET Branch0 = Branch0 - Cartons"
CurrentDb.Execute strSQL, dbFailOnError
Me.Requery
End Sub

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•