Solved For my benefit only?

Gasman

Enthusiastic Amateur
Local time
Today, 08:18
Joined
Sep 21, 2011
Messages
16,662
Helping someone on another forum, the query below did not work?
Code:
SELECT ItemT.ItemDescription, ItemT.Brand, ItemT.Model, ItemT.SerialNumber, ItemT.Size, ItemT.Color, ItemT.Dealer, ItemT.Category, ItemT.Room, ItemT.Cost, ItemT.Tax, ItemT.ReplValue, ItemT.FacWarrEXP, ItemT.ExtWarrEXP, ItemT.PurchaseDate
FROM ItemT
WHERE (((ItemT.Model) Like "*" & [Forms]![MainMenuF]![SearchBox] & "*"));

I did manage to get it to work using a Tempvar, then discovered that if I used

Code:
SELECT ItemT.ItemDescription, ItemT.Brand, ItemT.Model, ItemT.SerialNumber, ItemT.Size, ItemT.Color, ItemT.Dealer, ItemT.Category, ItemT.Room, ItemT.Cost, ItemT.Tax, ItemT.ReplValue, ItemT.FacWarrEXP, ItemT.ExtWarrEXP, ItemT.PurchaseDate
FROM ItemT
WHERE (((ItemT.Model) Like "*" & [Forms]![MainMenuF]![SearchBox].Value & "*"));

the query worked?

I also did have issues when trying to assign the control value to a TempVar, stating they could not contain objects. Used the .Value property on each.
So it appears that the default property was not being used for the control? Specifically using .Value worked?

Edit: Ok, I forgot the Tempvar assignment must have the .Value property of a control, but AFAIK the posters original code should have worked?
I have similar in some code of mine, just that I use a TempVar from an InputBox.

Just tried a new query and that also worked fine?
Code:
SELECT tblFoods.*, tblFoods.FoodID
FROM tblFoods
WHERE (((tblFoods.FoodID) Like "*" & [Forms]![frmDailyEntry]![sfcsfrmDaily].[Form]![cboFoodIDFK]& "*"));

Went back to that DB and removed the .Value property and now that works? :unsure:

Go figure. :)
 
Last edited:
Your code is out of context. Are you posting the string in a querydef or are you posting a string you are building in VBA? You can't use .Value in a querydef.
 
Your code is out of context. Are you posting the string in a querydef or are you posting a string you are building in VBA? You can't use .Value in a querydef.
I would beg to differ?
1747205477751.png

Querydef
Code:
SELECT ItemT.ItemDescription, ItemT.Brand, ItemT.Model, ItemT.SerialNumber, ItemT.Size, ItemT.Color, ItemT.Dealer, ItemT.Category, ItemT.Room, ItemT.Cost, ItemT.Tax, ItemT.ReplValue, ItemT.FacWarrEXP, ItemT.ExtWarrEXP, ItemT.PurchaseDate
FROM ItemT
WHERE (((ItemT.Model) Like "*" & [Forms]![MainMenuF]![SearchBox].value & "*"));

1747205610506.png
 

Users who are viewing this thread

Back
Top Bottom