I am a beginner at building Access Databases. I am attempting to build one currently at my job. My problem involves the DoCmd.RunSQL statement. I am attempting to run a SQL statement instead of an actual query in order to count records in a table that meet certain criteria. Here is the code I am using:
DoCmd.RunSQL "SELECT Count(*) AS [Count] FROM tblStatusAudit WHERE (((tblStatusAudit.Month)=[Forms]![frmStatusAudit]![cmbMonth]) AND ((tblStatusAudit.[Team Leader])=[Forms]![frmStatusAudit]![cmbTeamLeader]) AND ((tblStatusAudit.Status)=[Forms]![frmStatusAudit]![cmbStatus]));"
- I left it all on one line, so did not need the line breakers & _
I've been trying other methods, but was told this would be the simplest, b/c I just want to return a count to a text box on a form based on certain criteria. I've seen on some forums statements that you cannot do the statment with DoCmd.RunSQL "SELECT... because it you can only use the RunSQL command with action queries. Any ideas out there as to how to get around this problem?
DoCmd.RunSQL "SELECT Count(*) AS [Count] FROM tblStatusAudit WHERE (((tblStatusAudit.Month)=[Forms]![frmStatusAudit]![cmbMonth]) AND ((tblStatusAudit.[Team Leader])=[Forms]![frmStatusAudit]![cmbTeamLeader]) AND ((tblStatusAudit.Status)=[Forms]![frmStatusAudit]![cmbStatus]));"
- I left it all on one line, so did not need the line breakers & _
I've been trying other methods, but was told this would be the simplest, b/c I just want to return a count to a text box on a form based on certain criteria. I've seen on some forums statements that you cannot do the statment with DoCmd.RunSQL "SELECT... because it you can only use the RunSQL command with action queries. Any ideas out there as to how to get around this problem?