Query SQL into VBA SQL

swarv

Registered User.
Local time
Today, 08:00
Joined
Dec 2, 2008
Messages
196
I have the following line of code in a query and it returns a number value.

Code:
SELECT Count(1) AS [Occasions]
FROM absent
WHERE (((absent.Name)="Jo"));


I have pasted the following into the VBA code and it errors. How do I also get this to return a figure say into a variable or string?

Code:
SQLText = "SELECT Count(1) AS [Occasions] FROM absent WHERE (((absent.Name)=Combo0.Value));"

DoCmd.RunSQL SQLText

Thanks

Martin
 
RunSQL only works for action queries, such as Insert, Update, Delete. A select statement is neither. To get the desired results I suggest you use DLookup or DCount

David
 
ok great, sorted now. cheers, great help.
 

Users who are viewing this thread

Back
Top Bottom