Jump to content
Jambands.ca

Access question for any nerds out there


Groove Fetish

Recommended Posts

hi all...I tend not to post too often but I'm having troubles learning access and want to see if anyone can help me out.

I am trying to get a query to return some data and I can seem to get it to do what I want. I have a last name field and I want the datasbe to return to me any records that have certain names in them. But it is not just an equals to statement it should be a equals to or equals to or equals to....know what I mean??

so example. I have a record that says macdermid and a record that says baptiste and a record that says bosch. I want the baptiste records and macdermid records but not the bosch records. how does that statement look like.

this might be a really rudimentary question but I'm trying to teach myself access and its an uphill battle so far.

Thanks in advance for any help.

Link to comment
Share on other sites

so example. I have a record that says macdermid and a record that says baptiste and a record that says bosch. I want the baptiste records and macdermid records but not the bosch records. how does that statement look like.

I'm not sure if you're looking for something specific or generic but this would work:

select * from tablename where lastname in ('baptiste ', 'macdermid')

OR

select * from tablename where lastname = 'baptiste' or lastname = 'macdermid'

Link to comment
Share on other sites

First, take a closer look at my use of the "IN" keyword in my example.

As for this...

WHERE (((['C].[Award Date])<="2007") AND ((['C].[End Date])>="2007"));(['C] . [PI-lastname] = 'baptiste' or [PI-lastname] = 'macdermid')

I see a few things wrong here...

1. quotes used as delimiters should be single

i.e. '2007' and NOT "2007"

2. I'm not sure why you have a single quotation mark in this part: ['C].[Award Date]

3. Style note: although Access lets you, I'd avoid putting spaces in my field names; you'll avoid potential pitfalls

4. Remove that semi-colon and replace it with AND

Try those fixes and report back.

Link to comment
Share on other sites

so what happened when I switched to that was that it asked me for start dates parameters and end date parameters and last name parameters. but I thought those parameters were already in the string so shoudln't it have know that I wanted all dates >2007 and all dates ,2007 and macdermid and baptiste??? when I put in the parameters it actually retruned all the records in the database. so that one doesn't seem to work.

all this help is appreciated.

Link to comment
Share on other sites

here is the whoel statement:

SELECT ['C].[Award Date], ['C].[End Date], ['C].[PI- LastName], ['C].[PI- FirstName], ['C].[Grant Agency], ['C].[Grant Title], ['C].[$ Amount]

FROM ['C]

WHERE (((['C].[Award Date])<='2007') AND ((['C].[End Date])>='2007')) AND (['C][PI-lastname] = 'baptiste' or [PI-lastname] = 'macdermid')

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...