DSum() usage for calculated textbox on a continious form

A

Alex

I'm using DSum() to get a total for a textbox associated
with a table on a continious form.

Me.txtTotal1TextBox1.Value = DSum("TableField1",
strTableName)

Can I use this function to get a sum for a calculated
textbox on the continious form?

Thanks
 
A

Al Borges

Hi Alex:

I don't think that it's possible to DSum an unbound field. What I would
suggest are is something like this sample:

Dim ii As Long, iii as Long, rst As Recordset
ii = 0
iii = 0
Set rst = Forms![SOAPPARA].Form.RecordsetClone
'Clone form's recordset
With rst
..movefirst
..movelast
Do Until .EOF
ii = [OneNumberField] * [AnotherNumberField]
iii = iii + ii
..MoveNext
Loop
..Close
End With
[YourSumTotalUnboundField] = iii

That should do it... Just place it in the form's OnCurrent property.

Regards,
Al

1) You can attach a many-to-one subform
 
A

Alex

Thanks a lot.
I'll try it on Monday. It should work.
Could you advise what is [SOAPPARA]?

Regards,

Alex
-----Original Message-----
Hi Alex:

I don't think that it's possible to DSum an unbound field. What I would
suggest are is something like this sample:

Dim ii As Long, iii as Long, rst As Recordset
ii = 0
iii = 0
Set rst = Forms![SOAPPARA].Form.RecordsetClone
'Clone form's recordset
With rst
..movefirst
..movelast
Do Until .EOF
ii = [OneNumberField] * [AnotherNumberField]
iii = iii + ii
..MoveNext
Loop
..Close
End With
[YourSumTotalUnboundField] = iii

That should do it... Just place it in the form's OnCurrent property.

Regards,
Al

1) You can attach a many-to-one subform
I'm using DSum() to get a total for a textbox associated
with a table on a continious form.

Me.txtTotal1TextBox1.Value = DSum("TableField1",
strTableName)

Can I use this function to get a sum for a calculated
textbox on the continious form?

Thanks


.
 
A

Al Borges

Oh- actually that's a leftover from my database that I used to get the code.
It's a medical database table for SOAP notes (i.e. notes taken after a
patient is seen- subjective/objective/assessment/plan). Programming is my
"hobby"... I'm actually a physician.

Cheers,
Al

Alex said:
Thanks a lot.
I'll try it on Monday. It should work.
Could you advise what is [SOAPPARA]?

Regards,

Alex
-----Original Message-----
Hi Alex:

I don't think that it's possible to DSum an unbound field. What I would
suggest are is something like this sample:

Dim ii As Long, iii as Long, rst As Recordset
ii = 0
iii = 0
Set rst = Forms![SOAPPARA].Form.RecordsetClone
'Clone form's recordset
With rst
..movefirst
..movelast
Do Until .EOF
ii = [OneNumberField] * [AnotherNumberField]
iii = iii + ii
..MoveNext
Loop
..Close
End With
[YourSumTotalUnboundField] = iii

That should do it... Just place it in the form's OnCurrent property.

Regards,
Al

1) You can attach a many-to-one subform
I'm using DSum() to get a total for a textbox associated
with a table on a continious form.

Me.txtTotal1TextBox1.Value = DSum("TableField1",
strTableName)

Can I use this function to get a sum for a calculated
textbox on the continious form?

Thanks


.
 
A

Alex

Thanks Al,
Programming is getting to be my hobby as well.
-----Original Message-----
Oh- actually that's a leftover from my database that I used to get the code.
It's a medical database table for SOAP notes (i.e. notes taken after a
patient is seen- subjective/objective/assessment/plan). Programming is my
"hobby"... I'm actually a physician.

Cheers,
Al

Thanks a lot.
I'll try it on Monday. It should work.
Could you advise what is [SOAPPARA]?

Regards,

Alex
-----Original Message-----
Hi Alex:

I don't think that it's possible to DSum an unbound field. What I would
suggest are is something like this sample:

Dim ii As Long, iii as Long, rst As Recordset
ii = 0
iii = 0
Set rst = Forms![SOAPPARA].Form.RecordsetClone
'Clone form's recordset
With rst
..movefirst
..movelast
Do Until .EOF
ii = [OneNumberField] * [AnotherNumberField]
iii = iii + ii
..MoveNext
Loop
..Close
End With
[YourSumTotalUnboundField] = iii

That should do it... Just place it in the form's OnCurrent property.

Regards,
Al

1) You can attach a many-to-one subform
I'm using DSum() to get a total for a textbox associated
with a table on a continious form.

Me.txtTotal1TextBox1.Value = DSum("TableField1",
strTableName)

Can I use this function to get a sum for a calculated
textbox on the continious form?

Thanks


.


.
 

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