Passing value of DSum to text box after combo box update (1 Viewer)

Lilfiger19

New member
Local time
Today, 04:55
Joined
Mar 16, 2015
Messages
6
Hi,

I have a combo box that has a list of names in it. When I select a name, I am wanting to DSum a column in one of my tables based off of the name in the combobox and pass the value to a specific text box. The below code has worked in another database that I have set up but it is for 2010. i am currently writing this one in 2007. Can anyone please help me understand what I am doing wrong?

Code:
Private Sub cbxTM_AfterUpdate()

Me.txtCases = DSum("([Cases LY Var])", "tbl_Productivity", "[TM_and_ID]= '" & Nz([cbxTM]")

End Sub
 

informer

Registered User.
Local time
Today, 10:55
Joined
May 25, 2016
Messages
75
Hi

Try with

  • "[TM_and_ID]= '" & [cbxTM] & "'" if TM_and_ID is a string i.e. wrap combobox value with single quote
  • "[TM_and_ID]= " & [cbxTM] if TM_and_ID is a numeric i.e. without single quote
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:55
Joined
May 7, 2009
Messages
19,169
change this:

Me.txtCases = DSum("([Cases LY Var])", "tbl_Productivity", "[TM_and_ID]= '" & Nz([cbxTM]")


to:


Me.txtCases = DSum("([Cases LY Var])", "tbl_Productivity", "[TM_and_ID]= " & Nz([cbxTM], 0))
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:55
Joined
May 7, 2009
Messages
19,169
sorry page not found.
why not, if there is no value on the combo, it returns null and you cannot use null in comparison.
 

Users who are viewing this thread

Top Bottom