I'm trying to do something similar except using VBA on a form but can't get to grips with Count(*) in VBA. I get a string with my SQL statement and what I am then trying to do is use DoCmd.RunSQL
statement
This is popping an error saying that RunSQL is expecting a valid SQL statement. So obviously I'm having a formatting issue.
All I'm trying to do is count the amount of records that a search is coming back with for visual feedback purposes. Here is my gumf:
-
-
CSQL = "SELECT Count(*) As Counted FROM AccountCardRegister, AccountCardComments"
-
CSQL = CSQL & " WHERE AccountCardRegister.AccountCard LIKE '*" & Cardnumber & "*'"
-
DoCmd.RunSQL CSQL
-
-
I was hoping to popuate a textbox with Counted, the result.
Also tried this without the 'As Counted' in the string and had no joy.
Once again, question-a-rama from me, but any help gratefully received!