Query string to number

  • Thread starter Thread starter Benjamin
  • Start date Start date
B

Benjamin

Hello,

I have a query in 'build event' mode in Access that gives
a number as output:

SELECT COUNT(*) FROM warning;

If there is data in this Table I want to do someting with
it but anyway I was planning to do it like this in :

01 Dim Temp as String
02 Dim Number as Integer
03
04 Temp = "SELECT COUNT(*) FROM warning;"
05 Number = Str(Temp)
06
07 If Number > 0 Then .....

The following error occures on line 05: Run-Time Error 13
Type Mismatch

I don't know much about SQl and VB so I'm stuck can anyone
help me?
 
I know precious little about SQL, but a bit more of VB

VB and VBA have a set of functions that convert from one type of variable to
another - if you want to convert something to an integer, use CInt - e.g.,
05 Number = CInt(Temp)

That may not answer the global question of exactly what is the best way of
doing whatever it is that you are trying to do, but it will get you past the
Type Mismatch error.

James Cox
 
You can't and don't want to do several things from your code. Try:
Dim intNumber as Integer
intNumber = DCount("*","Warning")
If intNumber > 0 Then
 
Back
Top