Using DSUM function with textbox or CBO (1 Viewer)

vagues0ul

Registered User.
Local time
Today, 04:02
Joined
Sep 13, 2018
Messages
103
I am trying to calculate sales of agents seperately in the database. For total sales the DSUM is working fine. But if i try to bound it to some criteria (specific aget name) it gives ?NAME? error. Here is my code i applied for value selected from combobox

Code:
=DSum("[totalsales]","MainTable","[Agent_Name]='" & me.cbo1 & "'")

and here the code for textbox value criteria
Code:
=DSum("[totalsales]","MainTable","[Agent_Name]='" & me.filteragent & "'")
 

plog

Banishment Pending
Local time
Today, 06:02
Joined
May 11, 2011
Messages
11,611
It can't find Me.filteragent.

Either you've misspelled it (either the textbox itself or in the DSUM) or its not on the form at all---does this form have a subform?
 

vagues0ul

Registered User.
Local time
Today, 04:02
Joined
Sep 13, 2018
Messages
103
It can't find Me.filteragent.

Either you've misspelled it (either the textbox itself or in the DSUM) or its not on the form at all---does this form have a subform?


here is the detail of the items on my form...

1: There is no Subform on the form
2: Form is based on MainTable
3: filteragent is textbox bounded to MainTable
4: cbo1 is a comboBox peresent on that form taking values from Agent_Name field on MainTable
5: Filter agent is Unbounded textbox on the form
6: agentwisesum is the name of unbounded textbox on which i am appling the dsum function

i am also attaching the picture of form with controls on it. kindly guide where i am doing wrong.
 

Attachments

  • errordsum.png
    errordsum.png
    53.3 KB · Views: 99

plog

Banishment Pending
Local time
Today, 06:02
Joined
May 11, 2011
Messages
11,611
3: filteragent is textbox bounded to MainTable

This is not consistent with the image you posted. It clearly says 'Unbound' in the item you have labeled 'FILTERAGENT TEXTBOX'.

My guess is that you have misspelled the name of that control in either the DSum or on the control itself. They simply aren't matching.
 

vagues0ul

Registered User.
Local time
Today, 04:02
Joined
Sep 13, 2018
Messages
103
This is not consistent with the image you posted. It clearly says 'Unbound' in the item you have labeled 'FILTERAGENT TEXTBOX'.

My guess is that you have misspelled the name of that control in either the DSum or on the control itself. They simply aren't matching.

can you correct the formula accordin to the image. i am not getting it :banghead:
please:D
 

plog

Banishment Pending
Local time
Today, 06:02
Joined
May 11, 2011
Messages
11,611
No I cannot. I don't know what you have actually used as the name of your textbox. Can you post a sample database with the form in it?
 

vagues0ul

Registered User.
Local time
Today, 04:02
Joined
Sep 13, 2018
Messages
103
No I cannot. I don't know what you have actually used as the name of your textbox. Can you post a sample database with the form in it?

Just left for some work. I will attach the db as soon as i reach back office. Thanks mate :)
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:02
Joined
May 7, 2009
Messages
19,169
rename filteragent textbox to something else, ie. txtFilterAgent and use this in your dsum.
 

vagues0ul

Registered User.
Local time
Today, 04:02
Joined
Sep 13, 2018
Messages
103
rename filteragent textbox to something else, ie. txtFilterAgent and use this in your dsum.

i have renamed some controls but still not working. db is attached. kindly check
 

Attachments

  • Nebras1.accdb
    836 KB · Views: 57

plog

Banishment Pending
Local time
Today, 06:02
Joined
May 11, 2011
Messages
11,611
Can't check--unable to get into design view. Unlock this thing if you want help.
 

vagues0ul

Registered User.
Local time
Today, 04:02
Joined
Sep 13, 2018
Messages
103
Can't check--unable to get into design view. Unlock this thing if you want help.

press F11 and the navigation pane will show up. From there you can access design view of the table.
 

plog

Banishment Pending
Local time
Today, 06:02
Joined
May 11, 2011
Messages
11,611
F11 gets the navigation panel, unable to get into design view though.
 

vagues0ul

Registered User.
Local time
Today, 04:02
Joined
Sep 13, 2018
Messages
103
F11 gets the navigation panel, unable to get into design view though.

check now. I have disabled all the security modules now. Press f11 to display navigation pane and there you can select the design view.

Thanks for bearing with me:):D
 

Attachments

  • Nebras1.accdb
    1.1 MB · Views: 55

plog

Banishment Pending
Local time
Today, 06:02
Joined
May 11, 2011
Messages
11,611
Yup, gave you the answer a day ago: You have no control on that form called 'filteragent'.
 

vagues0ul

Registered User.
Local time
Today, 04:02
Joined
Sep 13, 2018
Messages
103
Yup, gave you the answer a day ago: You have no control on that form called 'filteragent'.

i have chagned its name to txtFindAsUTypeValue as you suggested. kindly update the code and attach the file that is running the dusm code. plz
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:02
Joined
May 7, 2009
Messages
19,169
see module1.
 

Attachments

  • Nebras1(1).zip
    224.7 KB · Views: 96

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:02
Joined
May 7, 2009
Messages
19,169
youre welcome.
 

Users who are viewing this thread

Top Bottom