View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jamie Collins Jamie Collins is offline
external usenet poster
 
Posts: 593
Default Case when statement gives type mismatch

(Henrik) wrote ...

I am trying to run some queries via VB and can get most of
them to work. However, when I use a Case when statment I get a type
missmatch error. After copying the debug.print to my query analyzer
or directly into Microsoft query, I don't have a problem. It's only
when I run if from VB.


Have you tried stopping execution after the stsql = <<text line,
capturing (e.g. in the Immediate Window) the value of stsql and
pasting this into the MS Query SQL window? Sometimes things go awry
when converting from plain text to VBA code so might be worth checking
again.

Jamie.

--