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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass Variable to DCount

Status
Not open for further replies.

dcurtis

Technical User
May 1, 2003
273
US
Is it possible to pass a variable to DCount?

Code:
=DCount("[CountMe]", "data source", "[Critera] = [i][b]variable[/b][/i]")
 
This seems like a controlsource in Access.

Then not directly, what you could do is create a public function to retreive the variable:

[tt]Public Function GetMyvariable() as <yourdatatype>
GetMyvariable = <name of variable>
End Function[/tt]

And then use the function name in the controlsrurce:

[tt]=DCount("[CountMe]", "data source", "[Critera] =" & GetMyvariable())[/tt]

- use appropriate qualifiers for the criteria (' for text, # for dates)

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top