Make a field using two tables (1 Viewer)

hrts4him

New member
Local time
Yesterday, 17:00
Joined
Jan 11, 2017
Messages
8
I have two tables with the same field lets call them a.flag and b.flag. I am making a join query of these two tables, and need to add a field that create an if.then.else criteria. If table a.flag is blank then b.flag else a.flag.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 17:00
Joined
Aug 30, 2003
Messages
36,137
If it's Null:

Nz(a.Flag, b.Flag)
 

hrts4him

New member
Local time
Yesterday, 17:00
Joined
Jan 11, 2017
Messages
8
This is what I have
Field: flag
Table: A
Show = yes (flag checked)
Criteria: Nz([a].[flag],.[flag])

Doesn't seem to work. Did I miss something?
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 17:00
Joined
Aug 30, 2003
Messages
36,137
I would expect it as a field, not a criteria. That's not the joining field is it?
 

hrts4him

New member
Local time
Yesterday, 17:00
Joined
Jan 11, 2017
Messages
8
That is not my key joining fields. I have two tables and I join them by c,d and e. I just need a to come from one table or the other. Would I need to do that outside of query design?
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 17:00
Joined
Aug 30, 2003
Messages
36,137
Just put that in a new field instead of the criteria. Access will alias it with Expr1, which you can change.
 

hrts4him

New member
Local time
Yesterday, 17:00
Joined
Jan 11, 2017
Messages
8
So it would look like
Field: new field name = nz (
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 17:00
Joined
Aug 30, 2003
Messages
36,137
Yes; have you tried it?
 

hrts4him

New member
Local time
Yesterday, 17:00
Joined
Jan 11, 2017
Messages
8
Yes and i get a parameter box but when i try to take expr out it adds it back
 

hrts4him

New member
Local time
Yesterday, 17:00
Joined
Jan 11, 2017
Messages
8
Ok so here is what i did and it worked
Test2: Nz
Worked great!
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 17:00
Joined
Aug 30, 2003
Messages
36,137
The parameter prompt is Access telling you it can't find something (whatever is listed in the box). Double check your spellings. You can't take out the Expr1, but you can change it to something of your choosing. Thus in design view you'd have:

DesiredFieldName: Nz(a.Flag, b.Flag)

If you're still stuck, can you attach the db here?
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 17:00
Joined
Aug 30, 2003
Messages
36,137
Ah you got it, good.
 

Users who are viewing this thread

Top Bottom