Search for a field that contains ampersand mark - sql

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.

Related

DLookup returning True for some values, and False for others

I am writing a program, and I need to be able to check whether a certain 'tag' exists, by looking at all the 'tags' in the column 'CowTagMain' of the 'CowTable' table.
The code I am using is,
DLookup("[CowTagMain]", "[CowTable]", "[CowTagMain]") = Tag ...
Where tag is a String, TagMain is the column, and MainTable, is the table I am fetching data from.
I am getting inconsistent results, when I try this with 18C, it returns true. While if I try this with 18, it returns false.
I would assume I am fundamentally misunderstanding how to use DLookup, but after searching the internet for hours I cannot understand what I am doing wrong.
Even just pointing me in the right direction would be very appreciated! I am new to working with Access and VBA.
The search criteria is not within the function WHERE CONDITION argument.
The field is text type so need apostrophe delimiters.
Consider:
If IsNull(DLookup("[CowTagMain]", "[CowTable]", "[CowTagMain]= '" & Tag & "'")) Then

Fake space between First and Last Name in excel

I have a spreadsheet that I have imported from one of our sites that we use for User Access. I am having trouble in the formatting of the spreadsheet in order to make it searchable and to use VLOOKUP. In the Full Name column, the first and last name look like they are separated by a space " " but it does not work that way when I try to split them into First Name and Last Name columns. It is almost like it is a fake space. I have tried many ways to make it a true space between the words but nothing has worked and none of my researching to find a solution to this problem has been found. Can anyone help me with figuring this out so I don't have to continue to delete the "fake space" and add a real space between the words?
Any help is much appreciated.
These are non-breaking spaces. I am guessing that this data is coming from an HTML source.
You can get your formulas to work by changing " " to CHAR(160), which will return the non-breaking space (ASCII code 160).

how can I disable rows in my gridview with datasource rowfilter?

How can I hide rows in my Gridview with a specific value? For example I want to hide all rows with column("dubletten_Vorschlaege") is empty
skmTabelle.SLXADRIUMDEVDataSet.Tables("SKM2").DefaultView.RowFilter = "Dubletten_Vorschlaege =Nothing"
said he cant find the column nothing?
skmTabelle.SLXADRIUMDEVDataSet.Tables("SKM2").DefaultView.RowFilter = "Dubletten_Vorschlaege ="""
said he cannot read the statement at """
I've never used rowfilter so I hope someone can explain.
Edit:
thx levi, it doesn't throw an exception now. But the gridview doesn't change. how do I do that? Do I need to use the fill query again?
on the formload event I have
Me.SKM2TableAdapter.Fillg(Me.SLXADRIUMDEVDataSet.SKM2, Module1.pkey)
which only selects the rows which are new.
for example I imported new 2000 rows it only shows them.
Do I need to use this statement again?
I would refer you to this site for a few tips on using rowfilter.
http://www.csharp-examples.net/dataview-rowfilter/
In your case, I think the proper way may be to write the string like this. I have followed a similar approach and this worked.
...DefaultView.RowFilter = "Dubletten_Vorschlaege ='" & "'"
you will notice that i add a single quote after the = and again add a single quote within double quotes after the &.
Also, I refer you to this StackOverflow link
How do I check for blank in DataView.RowFilter
The user simply added the line of code as this:
...DefaultView.RowFilter = "Dubletten_Vorschlaege = ''"
notice the two single qoutes before the ending double quote.

Check if string follows format

Basically I have created an acronym finding macro and it works well except it includes all of our reference numbers. Now unfortunately changing the search parameters won't work as many acronyms include both letters and numbers.
My idea was to compare the string, once found, and if it is in the reference number format e.g.
LetterNumberNumberLetterLetterNumberNumberNumberNumber
I will simply not include it.
I'm certain there must be a simple way of doing this and me not being able to locate it is a case of not knowing what to search for but anyway thank you in advance for the help.
Use LIKE:
'//LetterNumberNumberLetterLetterNumberNumberNumberNumber
if ucase$("A12BC3456") like "[A-Z][0-9][0-9][A-Z][A-Z][0-9][0-9][0-9][0-9]" then
msgbox "is ref no."

How to ignore blank criteria in queries in Access

I'm currently working with an update query, that works as expected until I add in criteria that makes the query not display any results (which I expected). The criteria is currently coming from textboxes on a form.
What I want to be able to do is, in the criteria line, specify that if the the textbox is blank with nothing in it, then the criteria should just skip that.
I've tried in the Criteria line:
[Forms]![Formname].[txtboxName] OR [Forms]![Formname].[txtboxName] Is Null
but that doesnt work.
Thank you for any help or guidance!
You should be able to use a wildcard:
Like [Forms]![Formname].[txtboxName] & "*"
How about:
where [whatever your field is] = [Forms]![Formname].[txtboxName]
OR Nz([Forms]![Formname].[txtboxName]) = ""
The use of Nz will catch both null values and zero length strings, which look null but are not.
If that doesn't work, please do as Remou requested. I.E. Update your question with the actual SQL query instead of just part of it.
try this:
Like IIF(IsNull([Forms]![Formname].[txtboxName])=Fasle;[Forms]![Formname].[txtboxName];"*")
*Note: my system default separator is ";", make sure what yours.
Enjoy the Ride