Solved Query to set time basted on another field... (1 Viewer)

Number11

Member
Local time
Today, 21:05
Joined
Jan 29, 2020
Messages
607
Hi, so i need to create a query that will look at a field within my table called DelWin and then put within the query 08:00 if AM or AD and if PM then 13:00

I have tried this but its not working:(


EARLIEST: IIf([DelWin]=AM,"08:00") Or IIf([DelWin]=PM,"13:00") Or IIf([DelWin]=AD,"08:00")
 

Number11

Member
Local time
Today, 21:05
Joined
Jan 29, 2020
Messages
607
Ok got it working now using for a single


EARLIEST: IIf([DelWin]>"AM","08:00") how to get them all now working together?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:05
Joined
Oct 29, 2018
Messages
21,454
How about?
Code:
EARLIEST: IIf([DelWin]="AM" Or [DelWin]="AD", #08:00#,IIf([DelWin]="PM",#13:00#,""))
 

Gasman

Enthusiastic Amateur
Local time
Today, 21:05
Joined
Sep 21, 2011
Messages
14,237
Try
Code:
EARLIEST: IIf([DelWin]='AM' OR DelWin = 'AD','08:00','13:00')
as any other tests your try might not be alphabetical?

HTH
 

Number11

Member
Local time
Today, 21:05
Joined
Jan 29, 2020
Messages
607
How about?
Code:
EARLIEST: IIf([DelWin]="AM" Or [DelWin]="AD", #08:00#,IIf([DelWin]="PM",#13:00#,""))
Yes this is working but getting error when the DelWin has no data - so need to add something to cover if NULL then say 08:00?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:05
Joined
Oct 29, 2018
Messages
21,454
Yes this is working but getting error when the DelWin has no data - so need to add something to cover if NULL then say 08:00?
Then how about?
Code:
EARLIEST: IIf(Nz([DelWin], "AM")="AM" Or [DelWin]="AD", #08:00#, IIf([DelWin]="PM", #13:00#, Null))
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 16:05
Joined
Feb 19, 2002
Messages
43,231
Or simplify:

EARLIEST: IIf(DelWin & "" ="PM", #13:00#, #08:00#))
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:05
Joined
Oct 29, 2018
Messages
21,454
Or simplify:

EARLIEST: IIf(DelWin & "" ="PM", #13:00#, #08:00#))
Nice! I didn't want to assume that AM, AD, and PM are the only possible entries in DelWin. I guess I should have asked. Cheers!
 

Users who are viewing this thread

Top Bottom