Access Query result different when opened in automation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a query that pulls information from three different linked tables.
(this might very well be the source of my problems but I dont understand why)
When I run the query manually in Access the result set is as I expect, but
when I use that query in a function in Access VBA, the where clause is
partially ignored. The part that is ignored is here:

(ServerDetails.SERVER_TYPE) Not Like "*Domain Controller*")

The full filter is here:
WHERE (((ServerDetails.ENVIRONMENT)="HOME") AND
((ServerDetails.SERVER_TYPE) Not Like "*Domain Controller*") AND
(((ServerDetails.DOMAIN_NAME)="BO") OR
((ServerDetails.DOMAIN_NAME)="DIDDLY")))

When run from VBA the query always ignores the condition:
(ServerDetails.SERVER_TYPE) Not Like "*Domain Controller*")
but it does use the other conditions just fine. I've even changed the where
clause to only have the part that VBA ignores and it is still ignored so it's
not due to being mixed in with the other conditions.

So my only guess is there is something about the "Not Like" condition that
doesn't run properly in VBA. Anyone have similar problems that can give me
some hints on what might be wrong here?
 
Ok, so I guess typing this out made me think a bit more clearly. I had to
change the '*' to an '%'. Even though '*' works fine when working manually
in Access, the automation requires '%' for wild-cards.
 
Back
Top