Programming tabular form

G

Guest

I have a tabular form that populates itself via a query. The fields I am
using is Customer, Legal, Date, Margin, and Set Change. The problem I am
having is I need the Margin of RecrodSet 2 to be subtracted from the Margin
of Recordset 1 and in the Set Change of RecordSet 2 to display the difference
as a + or -. Then for 3 to compare to 2, and to display the difference there.
I need this for every RecordSet on the form. How would I do this, and mainly
where would I place the code. I was thinking in the Form_Load with something
like this:

RecordSet(2).Set_Change.value = RecordSet(2).Margin.value -
RecordSet(1).Margin.Value

I have a feeling this is not correct, and there fore have not tried it as my
vba programming skills are not that advanced (yet). Any help would be greatly
appreciated.

C_Ascheman
 
G

Guest

It's not clear to me where your two recordsets are coming from. Do you have
code that is declaring recordset objects or are you talking about the form's
recordset. If so, why are there two? Perhaps you're not using the correct
terminology here.

Barry
 
A

Andy

Barry said:
It's not clear to me where your two recordsets are coming from. Do you have
code that is declaring recordset objects or are you talking about the form's
recordset. If so, why are there two? Perhaps you're not using the correct
terminology here.

Barry
Untested code...

using DAO and my A97 experience:

dim prevValue as integer

set rst = <your sql/source query> 'assuming sorted by date ascending
prevValue = rst.margin
rst.movenext
do until rst.eof
rst.setChange = rst.margin - prevValue
prevValue = rst.margin
rst.movenext
loop

I would make this a procedure that could be called to refresh the data
as needed.


hth,
Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top