By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,209 Members | 1,465 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,209 IT Pros & Developers. It's quick & easy.

Date Variable in DSum function

P: n/a
Dim vDateE As String
vDateE = #7/12/2005#
The following works to find Cost in TblExpenses for 7/12/2005:

MsgBox (DSum("Cost", "TblExpenses", "DateofPurchase = #7/12/2005#"))

However I have worked for hours to try and put a variable in place of
#7/12/2005#

Can someone give advice on this syntax -

Thank you in advance.

Michael Silane

Nov 13 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hello Mike

Try, MsgBox(DSum("Cost", "TblExpenses", "DateofPurchase = #" & vDateE
& " # "))

good luck,

Mike wrote:
Dim vDateE As String
vDateE = #7/12/2005#
The following works to find Cost in TblExpenses for 7/12/2005:

MsgBox (DSum("Cost", "TblExpenses", "DateofPurchase = #7/12/2005#"))

However I have worked for hours to try and put a variable in place of
#7/12/2005#

Can someone give advice on this syntax -

Thank you in advance.

Michael Silane


Nov 13 '05 #2

P: n/a
Mike wrote:
Dim vDateE As String
vDateE = #7/12/2005#
You might want to dim vDateE as a Date,
The following works to find Cost in TblExpenses for 7/12/2005:

MsgBox (DSum("Cost", "TblExpenses", "DateofPurchase = #7/12/2005#"))
The date is surrounded by # signs.
However I have worked for hours to try and put a variable in place of
#7/12/2005#

Can someone give advice on this syntax -
Well...you assigned a date, #7/12/2005# to the variable. But what is
contained between a "" is what makes up a string. And if you put
"DateofPurchase = vDateE"
you are basically asking something the computer something but what is a
DateofPurchase = vDateE?

So you need to split it out. And you need to surround the date variable
with #'s because its a date.
"DateofPurchase = #" & vDateE & "#"

Thank you in advance.

Michael Silane

Nov 13 '05 #3

P: n/a
Mike wrote:
Dim vDateE As String
vDateE = #7/12/2005#
The following works to find Cost in TblExpenses for 7/12/2005:

MsgBox (DSum("Cost", "TblExpenses", "DateofPurchase = #7/12/2005#"))

However I have worked for hours to try and put a variable in place of
#7/12/2005#

Can someone give advice on this syntax -


What the others said but also you should force the date into a specific
format (e.g. mm/dd/yyyy) so that it will work in other countries or a
visitor with his/her own laptop with different country settings won't
have a problem.
Nov 13 '05 #4

P: n/a
That worked - thanks again.

Mike S

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #5

P: n/a

Your syntax worked - did not have to Dim as Date
Thanks for the help.
Mike S

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #6

P: n/a
Thanks for the good suggestion

Mike S

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.