• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

SQL Questions

pcman2002b

Senior member
Okay trying to make a small Database to organize some things. I've got Reports, Forms, Tables all made up already. What I want to do is create an SQL Query that when run brings up a small window with a textbox. You type something into that text box, click OK and it runs a search based on the info you typed. I've done it before but my memory is terrible. Here is what I have so far.

SELECT * FROM Magazines
WHERE 'PMOM LastName' = ???????

I can't recal exactly how the WHERE line goes but where the question marks are is where I should be able to say something that tells Access to flag the user for input. PLease help. Thanks in advance.
 
Build a form that asks for the input and has a 'go' button.

The go button (when clicked) should put the query together and execute it.
 
The general form of an SQL statement is

SELECT columnsYouWant
FROM tablesToGetColumnsFrom
WHERE conditions

(there are also GROUP BY and HAVING clauses). If you want to compare some the elements of some column to a string literal you do it like columnName='Blah', for example

SELECT age
FROM people
WHERE name='Bob'

Gets the ages of all the rows where the name column is 'Bob' from the people table. Hope that helps.
 
The rest of the guys have missed your question, somewhat 🙂
You might want to get rid of those pesky single quotes around PMOM LastName, cause otherwise it wouldn't work. Also, you can't have column names consist of more than one word. That wouldn't fly either. So, no PMOM LastName, please 🙂. But, I think other than that, you are in good shape:

SELECT * FROM Magazines WHERE LastName = ? should pop-up the little user prompt where they enter that value.
Cheers
 
Back
Top