MS Access & Queries - sql

Looking for a bit of help for an Access/Query question pertaining to a homework assignment that has 6 separate questions. I have completed all but one. The assignment wants me to do the following query.
The name, unit price, and quantity ordered for all products purchased by a customer whose id is entered from the keyboard.
Is there a function I'm overlooking for the ID entity criteria? I've looked and searched but cannot find how to add that part into the query. Thanks in advance for any help.

You can accomplish this by making the ID criteria a parameter. Access will then pop up an input form that lets you enter the value of the parameter.
You can read more here and here.

Related

LIKE query with a varying number of LIKE’s

My current test revolves around a hypothetical database consisting of a PERSON table populated with their details.
I can undertake a simple LIKE query were I return the details of say a person or persons named Tom.
My question is how can I build a query were there may be multiple names and return their details?
I my exercise there is a checkbox list of names and I need to return the details for all those I select?
Thank you in advance for your assistance.

SQL query for the number of cases when a value of column1 (non-unique) can't be found within any record where column2 meets a basic criteria

I am doing a beginners' SQL tutorial and I started to wonder whether a simple SQL query on this table: http://www.sqlcourse2.com/items_ordered.html could tell the number of items (also 1) which have only been purchased more items at a time, so there is no record which contains the quantity column with a value of 1 AND the item. I am really beginner at this so please try to keep it simple.
Thank you in advance!
Welcome to the fascinating world of SQL.
Well - I'm not giving you the answer, but a hint (after all, it's a training and your own thinking and finding the solution would be the best way for you to learn something new).
The way you formulate your question is somewhat puzzling.
When I combine what you ask with what is possible with SQL, the question that would make sense to me would be that you need to list (or count, I did not understand that very well) the items (or the complete rows in the table with matching item, that was not clear either), that were never sold with a quantity of 1.
If that's what you need, you will need a subselect to get all distinct items that were sold with a quantity of 1, and select the rows from your base table whose item value is not in the list you get from the subselect.
Do you need more hints?
Marco

Querying via a form with value from textbox as criteria

The situation: metadata about biological specimens are collected in an Access table. The specimens come from human patients and patient data are collected in a separate table. To limit the amount of private health information we have hanging around, the patient database must be updated with new patients only when we actually receive samples from them.
So that the data entry workers know when they need to update the patient table, I want a button in the specimen data entry form that will pass an entered patient id value as criteria to a query.
The query looks like this right now:
SELECT Patients.[Patient id]
FROM Patients
WHERE (((Patients.[Patient id])=[Forms]![Specimen entry]![patient id]));
but it never has results, even when I run it from records that I know correspond to patients in the patient table. How do I fix this?
Suggestions about what to call this situation so that I can make better searches about it would also be appreciated. I'm an Access novice.
The query looks correct, but make sure the WHERE clause is comparing numbers to numbers or strings to strings (not a number to a string). Also confirm that the form and textbox names are correct. A quick test using your query worked for me.
Depending on how you plan to present the information, you can also dynamically create the query in VBA and then pass the information to the form.
For searching, I'd recommend some combination of access, dynamic, query, and vba.
alternative option
If you're only looking to see if a single patient exists in the table, it may be simpler to use the dlookup function:
If IsNull(DLookup("[Patient ID]", "Patients", "[Patient ID]='" & Me.Patient_ID & "'")) Then MsgBox "does not exist"
This will check to see if the patient exists (return a number) or does not exist (returns NULL).
https://support.office.com/en-us/article/DLookup-Function-8896cb03-e31f-45d1-86db-bed10dca5937

Dlookups with two or more criteria in Access 2007

I've searched around for a solution to this but am probably not asking the question correctly. I'm fairly new to Access but I need someone's help.
On my "CSEIrrelevants" form I have a couple of Dlookups to autupopulate after updating a previous field entry. They are CustomerName and AgreementName. Essentially, when someone enters a value into the CustomerID and AgreementID fields the subsequent two fields return values from CustomerDatabase Table from CustomerName and AgreementName columns.
The CustomerID Dlookup is working fine asthe references are unique but my problem arises when dealing with the Agreement IDs as these are not unique. Agreement number 1 (the most common agreement number) is returned every time a "1" is entered in the AgreementID field.
What I want is for my Dlookup to return the first instance in the AgreementName column on the CustomerDatabase Table when the CustomerID is A12345, for example.
Thanks in advance for any help on this one guys, much appreciated.
Sean

what is the best way to record users searches and count how many times it has been queried?

I am not sure what SQL is exactly, databases I think, would SQL be the thing to use?
I want it so that when a user types into a search box it displays a "did-you-mean" box, that also shows how many other people used that term but I will do later ;)
currently I just want the text to be saved into database (?) and also how many times it's been done.
(new to stackoverflow so sorry if format/whatever is bad)
You just need a three table named something like search_queries which has columns for: id, search_text, and count. Everytime somebody searches just increment the count column where search_text is equal to what they searched for. This is a really broad question though and you need to start by learning the basics and report back here with more specific questions.