Parameter in the Like clause of the criteria in MS Access - ms-access

I am looking to create a query in MS Access that searches by a name provided by the user. However, I would like to let the user enter only the beginning of the name. So, I would imagine a search criteria like this:
Like "[Enter name: ]*"
How do I achieve this effect?

You put parameter into quotes - so it become just part of string.
Like [Enter name: ] & "*"

Related

Use IIF and LIKE statement in critera column in queries, MS Access

I have homework from Microsoft Access for school and one of the tasks was to make a search form in query, where you type for example 1. grade, 2. grade or 1st year, etc... But the field contains the name of the classes such as IT1, IT2, E1A, E3C, etc... So I could not just make a search form with [Enter Class:] or Like [Enter Class:]&"*" in the criteria column. So I was thinking, that I can use the IIF statement but it doesn't work how I imagined. I think there is a problem with the LIKE statement. I read on forums, that the IIF statement should be used in the field column but I tried the simple examples in the criteria and it worked just fine. So my question is, how I can make a search form, where I type numerous letters with one certain number in it BUT only the number will be read and returned with the same number in classes. Example: I type to search 1. grade and the value will return classes IT1, E1A, E1B, E1C, E1D. This is the line I used in the criteria column:
Like IIf([Enter the grade:]="*1*";"*1*";IIf("*2*";"*2*";IIf("*3*";"*3*";IIf("*4*";"*4*"))))
Just to qualify, I'm beginner in access and databases overall, so there is big possibility, that I'm missing something.
Thank you for help! Cheers!
Assuming input will always start with a number and you want all values containing that number, consider:
WHERE fieldname LIKE "*" & Val([Enter grade]) & "*"
Also assumes values contain only single digit.

Reusing Parameters Passed to Query to Generate Form

I have a form in MS Access that uses a query to generate a form. The query looks something like this:
SELECT *
FROM PEOPLE
WHERE LAST_NAME LIKE [Enter Last Name] & "%";
This of course creates a pop-up to enter the last name to search. I want to do an action on the parameter [Enter Last Name], but I cannot figure out how to access this parameter. In a report I just set the value of a textbox to =[Enter Last Name]. Can anyone help me figure this out?
One thing you could do would be to add the parameter as an output column, e.g.
PARAMETERS [Enter Last Name] Text ( 255 );
SELECT People.*, [Enter Last Name] AS theParameter
FROM People
WHERE (((People.LastName) Like [Enter Last Name] & "*"));
Then you could refer to the [theParameter] column in the result set.

MS Access - What is the use of "!" , exclamation symbol

I am new to MS Acces and would like to know what does the symbo "!" mean.
For e.g.
1) What does "Tbl!Field" means and how does it differ from "Field" where "Tbl" is a atable name and "Field" is a column name.
I have some code that uses both the formats but not sure how do the two code differ
With recordsets, Tbl!Field would be the recordset (not table) name & the field name. You can also do Tbl("Field").
One advantage of Tbl("Field") is that you can use a variable name, like: Tbl(var1).
You may also see Tbl.Field, but I consider the period to be a property or method and shouldn't be used for fields.

Returning specific field from a matching record

I'm still a newbie at Access 2007, but I feel I am missing a understanding of a concept, when it comes to using user input from an unbound text box.
I'm trying to have the user input the record number (i.e. A12) and return another field in the matching record (such as the record status like "Opened")
I'm fiddling with DLookup to see if it will work through that method but no luck yet.
I may look into SELECT - SQL, but I haven't used that function yet and not sure if that will give me the result I'm looking for.
If this is something elementary to access programming (or databases in general), please let me know where I can read up on this.
I am currently using the MSDN website, but examples go much further to play with.
Edit:
My DLookup so far, which happens after update from user on Text12
Me.Text14.Value = DLookup("[RecordStatus]", "Orders", Text12.Value)
Thanks
Look closer at the third option (Criteria) in your DLookup() expression. You gave it only Text12.Value, which I assume is a string value like "A12".
The Criteria parameter should be like a WHERE clause in a query, without the word WHERE. IOW, some field's value = "A12". If that field is named "record_id", try this:
DLookup("RecordStatus", "Orders", "record_id = '" & Me.Text12 & "'")

Microsoft Access: How do I enter a comma in text filtering?

I want to do a text filter in Access searching for a pattern that includes a comma. But when I used , or put it in double quotes, Access gave me an error.
How do I search for text containing the comma character? Thanks.
First of all, your question is quite unclear. What do you mean by "text filter"? What do you mean by "searching for a pattern"? What kind of error message do you get?
For my answers below, I'm assuming that the data you want to search on is saved in a text field.
SQL allows you to do it like this:
SELECT * FROM CompanyName WHERE CompanyName LIKE '*,*'
If you're using the Access form filter property your filter should look like this:
strFilter = "CompanyName LIKE '*,*'"