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

How Do I Assign SQL Results to VBA Variables?

Status
Not open for further replies.

deepgrewal22

Instructor
May 2, 2005
108
How do I query a table using SQL in a VBA module and return the result into a VBA variable?

Code:
Dim intCount as Integer
Dim strSQL as String

strSQL = "SELECT COUNT(*) FROM <table_name>;"
DoCmd.RunSQL (strSQL)

'How does intCount get set to the result of strSQL?

Deep Grewal
"Microsoft Works" - oxymoron
 
I would take a look at a recordset.

Hope this helps.

"If it's stupid but works, it isn't stupid."
-Murphy's Military Laws
 
Thank you, Sir!

Deep Grewal
"Microsoft Works" - oxymoron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top