Running a Query

G

Guest

Hi,
Someone wants me to try and run this querry in Access to see what data it
brings. (it comes from a web form that pulls the e-mail addresses from a
table in an access database)

"SELECT email FROM Members ORDER BY lastname, firstname"

I don't know where to run it in access, I have tried creating a Query by
design and inserting it in there, but it doesn't seem to work. Can you help?
Thanks!
 
T

tina

I have tried creating a Query by
design and inserting it in there, but it doesn't seem to work.

are you getting an error message? if so, what? if not, what happens when you
open the query in datasheet view?

is the Members table in the Access database where you're building the query?
or is the table linked from another Access database?
 
G

Guest

I'm not really getting an error message, but I just don't know where I put
that line of code to test the query. Here is how I did it the first time:
members is a table name, loacted under the "tables" tab. I went to the Query
tab, clicked "Create Query in Design View" I entered that line of code in the
field name, and I also tried other fields, but none seemed to give the data I
was looking for.

I just need to be told where to put this to make it work.

Thanks.
 
T

tina

okay. in your "code" (it's called a SQL statement, or just SQL) make sure
the table name is spelt correctly, and also the field names. open a new
query in design view. on the menu bar, click View | SQL View. paste your SQL
into the window that opens. make sure you overwrite any characters that are
already in the window. then click on View | Design View, so you can see how
the SQL is presented in the query grid. (as you use queries, you can learn a
lot by switching between the design grid and the SQL view.)

hth
 
G

Guest

Thanks! It worked! One other question. How do I tell it to "ignore any fields
that are "null" or are empty"? Thanks.
 
T

tina

by adding a WHERE clause, also described as "setting a criteria on a field",
as

SELECT email FROM Members ORDER BY lastname, firstname WHERE SomeFieldName
Is Null

again, take a look at the query in Design View to see how Access translates
theSQL into the grid.

hth
 
G

Guest

When I use this:
SELECT email FROM Members ORDER BY lastname, firstname WHERE email IS Null

it says:
"Syntax error (missing operator) in query expression 'firstname WHERE email
IS Null'
 
T

tina

as Chaim says, i had the clauses in the wrong order. should be

SELECT email FROM MembersWHERE email IS Null ORDER BY lastname, firstname

i was asleep when i wrote the earlier post, obviously, sorry.

hth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top