select criteria

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i'm writing a query from a table TransactionData2005

the two fields i'm working with [LocationID] and [OldLocationID]

my criteria is based on [LocationID] containing "CO*" or "DO*"

if this criteria is not met, i want to select [OldLocationID]

how would i write this?
 
Samuel,

Assuming you're using Access' query designer, you would do the following:

LocID: IIf(([LocationID] Like "CO*") Or ([LocationID] Like "DO*"),[LocationID]
,[OldLocationID])

If you're building the SQL statement in VBA, it's slightly more complicated.

Hope this helps,

Sam
i'm writing a query from a table TransactionData2005

the two fields i'm working with [LocationID] and [OldLocationID]

my criteria is based on [LocationID] containing "CO*" or "DO*"

if this criteria is not met, i want to select [OldLocationID]

how would i write this?
 
is there a way to use this using a field as the criteria instead of "CO*"?

OfficeDev18 via AccessMonster.com said:
Samuel,

Assuming you're using Access' query designer, you would do the following:

LocID: IIf(([LocationID] Like "CO*") Or ([LocationID] Like "DO*"),[LocationID]
,[OldLocationID])

If you're building the SQL statement in VBA, it's slightly more complicated.

Hope this helps,

Sam
i'm writing a query from a table TransactionData2005

the two fields i'm working with [LocationID] and [OldLocationID]

my criteria is based on [LocationID] containing "CO*" or "DO*"

if this criteria is not met, i want to select [OldLocationID]

how would i write this?
 
Example:

LocID: IIf(([LocationID] Like [SomeFieldName] & "*" ,[LocationID],
[OldLocationID])

SomeFieldName must be in the same record as the other fields.
DawnTreader said:
is there a way to use this using a field as the criteria instead of "CO*"?

OfficeDev18 via AccessMonster.com said:
Samuel,

Assuming you're using Access' query designer, you would do the following:

LocID: IIf(([LocationID] Like "CO*") Or ([LocationID] Like
"DO*"),[LocationID]
,[OldLocationID])

If you're building the SQL statement in VBA, it's slightly more
complicated.

Hope this helps,

Sam
i'm writing a query from a table TransactionData2005

the two fields i'm working with [LocationID] and [OldLocationID]

my criteria is based on [LocationID] containing "CO*" or "DO*"

if this criteria is not met, i want to select [OldLocationID]

how would i write this?
 
could you put in a reference to another table? [mytable]![somefield] for
example?

John Spencer said:
Example:

LocID: IIf(([LocationID] Like [SomeFieldName] & "*" ,[LocationID],
[OldLocationID])

SomeFieldName must be in the same record as the other fields.
DawnTreader said:
is there a way to use this using a field as the criteria instead of "CO*"?

OfficeDev18 via AccessMonster.com said:
Samuel,

Assuming you're using Access' query designer, you would do the following:

LocID: IIf(([LocationID] Like "CO*") Or ([LocationID] Like
"DO*"),[LocationID]
,[OldLocationID])

If you're building the SQL statement in VBA, it's slightly more
complicated.

Hope this helps,

Sam

samuel wrote:
i'm writing a query from a table TransactionData2005

the two fields i'm working with [LocationID] and [OldLocationID]

my criteria is based on [LocationID] containing "CO*" or "DO*"

if this criteria is not met, i want to select [OldLocationID]

how would i write this?
 
Yes, but only if the table is included in the query (in the from clause).

I would suggest you try it and if it fails then post a question with the SQL
(Menu: View: SQL) text. And a specific informtion on what problem you are
trying to solve.


DawnTreader said:
could you put in a reference to another table? [mytable]![somefield] for
example?

John Spencer said:
Example:

LocID: IIf(([LocationID] Like [SomeFieldName] & "*" ,[LocationID],
[OldLocationID])

SomeFieldName must be in the same record as the other fields.
DawnTreader said:
is there a way to use this using a field as the criteria instead of
"CO*"?

:

Samuel,

Assuming you're using Access' query designer, you would do the
following:

LocID: IIf(([LocationID] Like "CO*") Or ([LocationID] Like
"DO*"),[LocationID]
,[OldLocationID])

If you're building the SQL statement in VBA, it's slightly more
complicated.

Hope this helps,

Sam

samuel wrote:
i'm writing a query from a table TransactionData2005

the two fields i'm working with [LocationID] and [OldLocationID]

my criteria is based on [LocationID] containing "CO*" or "DO*"

if this criteria is not met, i want to select [OldLocationID]

how would i write this?
 

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

Back
Top