• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 382
  • Last Modified:

DSum code not working

What is wrong with this DSum code?

Me.txtBooked = DSum("[QuotedSales]", "OpenJob", "[BookedDate] = between " & Chr(34) & Forms!frmSelectDateRange!txtStart & Chr(34)) And " & Chr(34) & Forms!frmSelectDateRange!txtEnd & Chr(34))" And [ProductCode] <> 350

--Steve
0
SteveL13
Asked:
SteveL13
  • 3
  • 3
  • 2
1 Solution
 
Rey Obrero (Capricorn1)Commented:
is ProductCode a Number or Text data type?

if Number use this
Me.txtBooked = DSum("[QuotedSales]", "OpenJob", "[BookedDate] = between  #" & Forms!frmSelectDateRange!txtStart & "# And   #" & Forms!frmSelectDateRange!txtEnd & "# And [ProductCode] <> 350")

if Text

Me.txtBooked = DSum("[QuotedSales]", "OpenJob", "[BookedDate] = between  #" & Forms!frmSelectDateRange!txtStart & "# And   #" & Forms!frmSelectDateRange!txtEnd & "# And [ProductCode] <> '350'")
0
 
SteveL13Author Commented:
It is a number field.  I am running the code...

Me.txtBooked = DSum("[QuotedSales]", "OpenJob", "[BookedDate] = between  #" & Forms!frmSelectDateRange!txtStart & "# And   #" & Forms!frmSelectDateRange!txtEnd & "# And [ProductCode] <> 350")

On an afterupdate event of the field, "txtEnd" and get a syntax error message.

???

0
 
SteveL13Author Commented:
 Runtime error 3075... (Missing operator)
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
LucasMS Dynamics DeveloperCommented:
Try this:

Me.txtBooked = DSum("[QuotedSales]", "OpenJob", "[BookedDate] = between" & "#" & Forms!frmSelectDateRange!txtStart & "#" & " And " & "#" & Forms!frmSelectDateRange!txtEnd & "#" & " And [ProductCode] <> 350")
0
 
SteveL13Author Commented:
Sorry.  That did not work either.  Here is the exact error I'm getting...

 screen shot
0
 
LucasMS Dynamics DeveloperCommented:
Why does it have a ' at the end of 350? you also need a space after the between.  I changed it a bit.  You might have to remove the last ".

Me.txtBooked = DSum("[QuotedSales]", "OpenJob", "[ProductCode] <> 350 and [BookedDate] = between " & "#" & Forms!frmSelectDateRange!txtStart & "#" & " And " & "#" & Forms!frmSelectDateRange!txtEnd & "#" & "")
0
 
LucasMS Dynamics DeveloperCommented:
Oops:

Me.txtBooked = DSum("[QuotedSales]", "OpenJob", "[ProductCode] <> 350 and [BookedDate] between " & "#" & Forms!frmSelectDateRange!txtStart & "#" & " And " & "#" & Forms!frmSelectDateRange!txtEnd & "#" & "")
0
 
Rey Obrero (Capricorn1)Commented:
sorry you don't need the "=" sign


Me.txtBooked = DSum("[QuotedSales]", "OpenJob", "[BookedDate]  between  #" & Forms!frmSelectDateRange!txtStart & "# And   #" & Forms!frmSelectDateRange!txtEnd & "# And [ProductCode] <> 350")
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now