DSum expression problem

ravencrt

New member
Local time
Today, 21:17
Joined
Jan 4, 2011
Messages
8
I need help with dsum function. I have a form that the user will filter. At the footer of the form I have a textbox and a button, when the user presses the button I want to change the controlsourse of the textbox but unfortunatly it give me a error saying #Name?
Here is the code:

strLinkCriteria = Me.Filter
strLinkCriteria = Replace(strLinkCriteria, Chr(34), Chr(39))
strLinkCriteria = Replace(strLinkCriteria, "Date()", "GetDate()")
If strLinkCriteria <> "" Then
Text187.ControlSource = DSum("Volume", "QryCommandesDetails_LG_subform_volum", strLinkCriteria)
Else
Text187.ControlSource = DSum("Volume", "QryCommandesDetails_LG_subform_volum")
End If

I've checked the name of the field Volume and the name of the query and they both are correct. What am I missing?
 
Access wouldn't know what GetDate() is, unless that's a function you've created (it's a T-SQL function only as far as I know). You should leave it as Date(). Add

Debug.Print strLinkCriteria

right before the If and run the code. That will print out the finished string to the VBA Immediate window. What does it look like? Also, I'd probably set the value property rather than the control source, unless you want to leave the DSum() itself there as the control source.
 

Users who are viewing this thread

Back
Top Bottom