Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DCount trouble with variable 2

Status
Not open for further replies.

alr0

Programmer
May 9, 2001
211
US
Hi All,

I am creating a DCount statement with rather complex criteria. (Access03) The simple version below works if I use a hard coded date but I am having trouble using the VBA variable dtDateBegin.

DCount("importid", "tblimports", ("dateimported >= #dtDateBegin# "))

DCount("importid", "tblimports", ("dateimported >= #7/17/2006 8:22:47 AM# "))

I have tried several concatenations, with and without # enclosures.

This is probably pretty simple, thanks for any clues.

alr

_____________________________________
If a large part of intelligence is the ability to generalize, it is ironic that a large part of what we call wisdom is the ability not to generalize.
 
Can you post the declaration and the filling of the variable dtDateBegin please. This may be where you are having difficulties. You should have to concantenate the variable into the string something like >=#" & dtdatebegin & "# to fill it properly.

The declaration and filling of the variable will be helpful here.

Thanks


Andy Baldwin

"Testing is the most overlooked programming language on the books!
 
Hi, alr,

This does not work?:
Code:
DCount("importid", "tblimports", "dateimported >= #" & dtDateBegin & "#")
HTH,

Ken S.
 
Hi Andy & Ken,

Thank you both for looking into this.

Ken, you got it. It worked the first time. It's a little embarassing but I have never seen that specific syntax before. It just never came up and I did not see it in the knowledge base.

Thanks again,

alr

_____________________________________
If a large part of intelligence is the ability to generalize, it is ironic that a large part of what we call wisdom is the ability not to generalize.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top