You would need to sort by date in the DSum. Howver, if you're not storing
the time as well as the date (which seems likely) this method is more prone
to error since many records will have the same date entry.You could sort by
date AND ID, like this:
= DSum("Amount", "YourTable", "Date* <= #" & txtDate** & "# AND ID <= " &
[ID])
but this may also give unexpected results if you care about the order within
a certain date. However, it's really the only option, so you should pobably
go for it.
*I hope this isn't really the name of your field. "Date" is a reserved word
and should be avoided when considering field (or other object) names. Look
up reserved wordsin online help.
**Your form control names should be different from the fields in the bound
recordset. I usually use a prefix designating the type of control I am
naming: "txt" for textbox, "cmb" for combo, etc.
HTH,
Bob Barrows
Quote:
> All the posts make one undiscussed assumption, i.e. that you have an
> ID that is sequential from the top of your list to the current record
> when using the DSum function.
> What about the situation where you have a set of transactions (each of
> which DO have a unique key) but there is no guarantee that the ID's
> are in date sequence?
> I am doing a checkbook program, but cannot guarantee that the ID's
> will necessarily sort lowest to largest by date. This could happen if
> a person entered the transactions out of date sequence.
> E.g.
> AutoNo Date Amount
> 1 1/1/01 +46.45
> 2 1/4/01 -35.23
> 3 1/3/01 +245.33
> etc.
> Keith
Quote:
> > On a report, the data is fixed, so RunningSum is easy.
> > Your form could be filtered or reordered at any time. Should Access
> > show only the running sum for the filtered records? Should the
> > balance be reworked if the records are reordered?
> > The checkbook balance is usually a matter of using a calculated
> > control that has a DSum() expression. Assuming:
> > - primary key named "ID", and
> > - Amount field that's positive for credits and negative for debits,
> > the ControlSource of your text box will be something like this:
> > = DSum("Amount", "YourTable", "ID <= " & [ID])
> > > Got the running sum on the report..its great for doing a checkbook -
> > > balances.
> > > Now, i want to show the same data on a form. How can this be done?