Microsoft Access search query - sql

I have a search query that compare the text from text box with my database table untill now I have no problem and every thing works good .. but when I want to make the query compare part of text with database here I have the problem. For example if I have record "USA". I want to type "us" in the text box the query must have a result "USA".
Here is my query:
SELECT Goods.ID, Goods.Name, Goods.Description,
Goods.CatID, Goods.SubCatId, Goods.DealerPrice,
Goods.SuperDealerPrice, Goods.EndUserPrice,
Goods.BarCode, Goods.Quantity
FROM Goods
WHERE (((Goods.CatID)=Forms!Form1!Text58)
And ((Forms!Form1!Text78) Is Null))
Or (((Goods.SubCatId)=Forms!Form1!Text78))
Or (((Goods.BarCode)=Forms!Form1!Text115))
Or (((Goods.Name)= Forms!Form1!Text115))
Or ((Goods.Description) Like [Forms]![Form1]![Text115]);
I know in sql I must to put "%" in the query but it's not work.
Can any one show me how to make the change on this code here and I will make the others:
((Goods.Description) Like [Forms]![Form1]![Text115]);

Use * in Access.
((Goods.Description) Like "*" & [Forms]![Form1]![Text115] & "*")
Or you can use alike if you plan to use %.
((Goods.Description) alike "%" & [Forms]![Form1]![Text115] & "%")

Related

How to avoid & popup when SQL query contain '&' letter?

I am writing a migration script where I replaced html encoded values by original values like & will get replaced by &. So my SQL query has & letter but when I execute this query it give me popup for every & to replace that character which is as shown below
After clicking on OK its giving anexpecetd result but actually this popup should not come for every &. What should have to do to avoid this popup?
At the top of your script, add:
set define off;

Search for a field that contains ampersand mark

I have a field that contains values such as
fish & chips
When I try to search for this field
Select * From Menu WHERE FoodItem = 'fish & chips'
It returns nothing despite all the matching entries in the table.
Now I realised this is an issue with the ampersand(&) mark. One workaround would be to change all 'fish & chips' to 'fish and chips'. But I would rather not play with that many data.
Also, I don't want to use LIKE or CONTAINS because I want to match things exactly.
How can I write a WHERE statement that will work with the & mark?
Thanks!
Cheers!
Some information is missing. It simply just works given the description of information provided unless you've got a trigger or something that is stripping the & on INSERT or UPDATE.
Verify that the data in the table actually still contains the &.
For example, as you can see here, searching on that character in your string is returning as it should.

Alternative or Suggestions for DoCmd.ApplyFilter?

I have a form that is bound to the main table in my access database. There are 5 comboboxes which shows the description of the IDs that are stored in the main database.
TruckModelID is stored in the tblTruckList and relates to the TruckModelID in tblTruckModel. TruckModelName is stored in tblTruckModel.
I can make a simple search function where I can enter the ID but the user will not know the ID for specific models. How do I make some kind of search that can look at the value in txtFindTruck (my search field) and compare it to the name and then pick the correct ID and return the records from TruckList with the correct ID?
This is what I have been using when looking at values in tblMain:
DoCmd.ApplyFilter "", "[TruckID] Like ""*"" & Forms![Ändra Truck]!txtFindTruck & ""*"""
This is basically what I want:
DoCmd.ApplyFilter "", "[cmbTruckModelName] Like ""*"" & Forms![Ändra Truck]!txtFindTruck & ""*"""
However the actual value that the form uses is the TruckModelID not the TruckModelName
I am sure I have missed something in the description that makes it hard to understand, please do not hesitate to ask me anything :D also any help will be much appreciated.
You can use the SQL IN clause to filter by a different query, like this:
DoCmd.ApplyFilter "", "[TruckID] IN(" & _
"SELECT TruckID From MyTable WHERE TruckModelName LIKE ""*"" & Forms![Ändra Truck]!txtFindTruck & ""*"")"
Fill in the blanks like your table name and it should work.
However, this might not be the best solution to your problem. If you are using a combo box, you can use a hidden ID column to do the searching, and include the actual model names in the combo box, which might be more user friendly.
See How to hide columns in a ComboBox dropdown? on how to hide columns.

SSRS expression and free text in the same textbox

Is it possible?
I would like to place the following inside a textbox:
There are =Count("MyDataSet") records found.
But if I place that in the expression on the textbox it just displays as above instead of getting the value.
Now I know if I were to split the above in two different textbox works ok but for spacing reasons it would be better if I could just use one?
Is that possible?
You need an expression in the textbox that specifies the text strings and concatenates these to your count value, something like:
="There are " & CountRows("MyDataSet") & " records found"

concatenation of two measures in mdx query result

is it possible to concatenate two measures values into one cell ?
this is the sample query but it doesnt work:
WITH member [Measures].[tmp] as ([Measures].[m1] + " " + [Measures].[m2])
SELECT {[Brand].[Brand Name].[Brand Name]} ON ROWS, {[Measures].[tmp]} ON COLUMNS FROM [DEVEL]
thank You very much for any help
Perhaps you need to make it clear you are after the .Value of the member, otherwise the MDX parser thinks you mean the member (object) itself?
WITH MEMBER [Measures].[tmp] AS '[Measures].[m1].Value & " " & [Measures].[m2].Value'
I've also tweaked the syntax a bit: I think you need & to concatenate (like VBA, which MDX understands if using MS OLAP), and you should need single quotes around the definition after the AS.
Alternatively, if you are using your own code to call MDX, then you can read the cell values yourself, and concatenate anything you want before displaying it?