DSum

A

Anthony Viscomi

I have the following VBA that is executed on a form's "Load" event:

Dim TotalDueX As Integer
TotalDueX = DSum("[Cost]", "dbo_course", "[SS]" = Me.SS)
Me.Total_Due = TotalDueX

End Sub

I receive an "Invalid use of Null" error, any thoughts?
Thanks!
Anthony
 
D

Dirk Goldgar

Anthony Viscomi said:
I have the following VBA that is executed on a form's "Load" event:

Dim TotalDueX As Integer
TotalDueX = DSum("[Cost]", "dbo_course", "[SS]" = Me.SS)
Me.Total_Due = TotalDueX

End Sub

I receive an "Invalid use of Null" error, any thoughts?
Thanks!
Anthony

*If* Me.SS has a value yet, of which I'm not sure, you still need to put
the equals sign in the criterion inside the quotes. Assuming that SS is
a number field, you might use

TotalDueX = DSum("Cost", "dbo_course", "SS = " & Me.SS)

If SS is a text field, you might use

TotalDueX = DSum("Cost", "dbo_course", "SS = '" & Me.SS & "'")

However, I'm not sure whether SS will have a value in the form's Load
event; you may have to wait for the Current event, I'm not sure.
 
F

fredg

I have the following VBA that is executed on a form's "Load" event:

Dim TotalDueX As Integer
TotalDueX = DSum("[Cost]", "dbo_course", "[SS]" = Me.SS)
Me.Total_Due = TotalDueX

End Sub

I receive an "Invalid use of Null" error, any thoughts?
Thanks!
Anthony

The syntax of the where clause is incorrect.
What datatype is [SS]?
If [SS] is a Number datatype:

TotalDueX = DSum("[Cost]", "[dbo_course]", "[SS] = " & Me!SS)

If [SS] is Text Datatype:
TotalDueX = DSum("[Cost]", "[dbo_course]", "[SS] = '" & Me!SS & "'")
 
A

Anthony Viscomi

Thanks!
fredg said:
I have the following VBA that is executed on a form's "Load" event:

Dim TotalDueX As Integer
TotalDueX = DSum("[Cost]", "dbo_course", "[SS]" = Me.SS)
Me.Total_Due = TotalDueX

End Sub

I receive an "Invalid use of Null" error, any thoughts?
Thanks!
Anthony

The syntax of the where clause is incorrect.
What datatype is [SS]?
If [SS] is a Number datatype:

TotalDueX = DSum("[Cost]", "[dbo_course]", "[SS] = " & Me!SS)

If [SS] is Text Datatype:
TotalDueX = DSum("[Cost]", "[dbo_course]", "[SS] = '" & Me!SS & "'")
 

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