Query with TempVars help

gwarhn

New member
Local time
Today, 23:12
Joined
May 23, 2013
Messages
2
Hi all. I'm hoping someone is able to help me with a problem I'm stuck with. :banghead:

I'm trying to create a query that supplies a form with data. I want to pass a TempVar to the query that is selected a from previously opened form.

The TempVar is setting correctly and I can see if this if I place a textbox (NewCID) on the form showing the TempVar. The problem I have is displaying on the records according to that TempVar. If I set the query manually, i.e. "|Test|" then records are displayed but if I use the TempVar, which also displays |Test| then no records are brought back.

I'm not sure what I'm doing wrong but I think it's something do with the vertical bar and that fact the field I'm searching on is a memo field, both of which I've no control over. I also have to use the Like statement because of this.

Here's the query that works...

SELECT *
FROM dbo_ASSETS
WHERE ASSET_CID Like "|Test|"


and the one that I want to use, that doesn't...

SELECT *
FROM dbo_ASSETS
WHERE ASSET_CID Like [TempVars]![tmpvarCID]


I've even tried referring to the textbox instead of the TempVar, i.e.

SELECT *
FROM dbo_ASSETS
WHERE ASSET_CID Like [Forms]![AssetsCID]![NewCID]


but that doesn't work either.

Any help would be gratefully received.

Thank you
Richard
 
Interesting that Tempvars is recognized in a query.

I wonder if your Like clause needs to be enhanced:

Like "*" & [Tempvars]![varname] & "*"
 
You're amazing, it worked a treat.
Thank you! :)
 

Users who are viewing this thread

Back
Top Bottom