0

I have a table titled MIUInfo. In it there are three columns; MIUID, Latitude, and Longitude.
In it I'm running the following query which gets the number of MIUIDs in the criteria range.

SELECT Count(MIUInfo.MIUID)
      From MIUInfo 
      WHERE ((MIUInfo.Latitude Between " & minLat & " And " & maxLat & ") 
      AND (MIUInfo.Longitude Between " & minLong & " And " & maxLong & "))

I need to set the result of this query equal to a variable in VBA so that I can use it as a condition for a loop. I can't figure out how to do this.

Also, when I try to use the DoCmd.RunSQL command I get an error:

Run-time error '2342': A RunSQL action requires an argument of an SQL statement.

The only difference between this query and others I'm running with the DoCmd.RunSQL is that all of the other select queries are generating a new table.

1
  • And my question is getting down-voted because..?
    – Bryan
    Jun 25, 2009 at 19:52

2 Answers 2

0

In Access the easiest way to do this is with the DCount function:

Total = DCount("MIUInfo.MIUID", "MIUInfo", "(MIUInfo.Latitude Between " & minLat & " And " & maxLat & ") AND (MIUInfo.Longitude Between " & minLong & " And " & maxLong & ")")
0
0

Use DCOUNT

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.