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

Assigning a query output to a VBA variable 1

Status
Not open for further replies.

teach314

Technical User
Jul 29, 2011
183
CA
I have a feeling I am missing something obvious. Consider the code fragment:

Code:
Dim db as DAO.Database,strSQL As String, strQryCount As String, intID_Count As Integer

    strSQL = "Select Count(ID) AS ID_Count FROM qry_X;"

    Set db = CurrentDb()
    Set MyQueryDef = db.CreateQueryDef(strQryCount, strSQL)
    DoCmd.OpenQuery strQryCount

    intID_Count =   ???????

    code continues.....

Here is my question - the query outputs a single number, say 50, in a 'one-celled' query output. How do I assign this value to the variable intID_Count?

Thanks in advance
 
Code:
Dim intID_Count As Integer
intID_Count = DCount("ID", "qry_X")
code continues.....

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top