A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

IIF in Query



 
 
Thread Tools Display Modes
  #1  
Old October 9th, 2007, 07:54 PM posted to microsoft.public.access.queries
D Collins
external usenet poster
 
Posts: 6
Default IIF in Query

I have a query that derives its criteria from a form. On the form I have 2
fields: Beginning Date and Ending Date.

Here's what I want to accomplish: If the Start date is null, then have it
use =End Date; otherwise if the Start date and End date are filled in, I
need it to say Between start date and end date.

iif(isnull(Forms!frmMyForm![txtStartDate]),tblMyTable!dtmStartDate =
Forms!frmMyForm![txtEndDate], tblMyTable!dtmStartDate between
Forms!MyForm!txtStartDate and Forms!frmMyForm!txtEndDate)

It seems that it doesn't recognize the operators of less than or equal to
nor the Between statement.

Either I am writing the syntax incorrectly or it cannot be done in an IIF
statement.

Thanks,
D.Collins
  #2  
Old October 9th, 2007, 09:21 PM posted to microsoft.public.access.queries
Marshall Barton
external usenet poster
 
Posts: 5,361
Default IIF in Query

D Collins wrote:

I have a query that derives its criteria from a form. On the form I have 2
fields: Beginning Date and Ending Date.

Here's what I want to accomplish: If the Start date is null, then have it
use =End Date; otherwise if the Start date and End date are filled in, I
need it to say Between start date and end date.

iif(isnull(Forms!frmMyForm![txtStartDate]),tblMyTable!dtmStartDate =
Forms!frmMyForm![txtEndDate], tblMyTable!dtmStartDate between
Forms!MyForm!txtStartDate and Forms!frmMyForm!txtEndDate)

It seems that it doesn't recognize the operators of less than or equal to
nor the Between statement.



Son't even try to use Between in this kind of situation.
Use = and = instead.

I think I would use this kind of criteria:

=Nz(Forms!frmMyForm!txtStartDate,#1/1/1000#) AND

=Forms!frmMyForm!txtEndDate
--
Marsh
MVP [MS Access]
  #3  
Old October 9th, 2007, 09:57 PM posted to microsoft.public.access.queries
D Collins
external usenet poster
 
Posts: 6
Default IIF in Query

Marshall,

Thank you so much. I knew there had to be a way to do this. I really
appreciate it.

Thanks,
D.

"Marshall Barton" wrote:

D Collins wrote:

I have a query that derives its criteria from a form. On the form I have 2
fields: Beginning Date and Ending Date.

Here's what I want to accomplish: If the Start date is null, then have it
use =End Date; otherwise if the Start date and End date are filled in, I
need it to say Between start date and end date.

iif(isnull(Forms!frmMyForm![txtStartDate]),tblMyTable!dtmStartDate =
Forms!frmMyForm![txtEndDate], tblMyTable!dtmStartDate between
Forms!MyForm!txtStartDate and Forms!frmMyForm!txtEndDate)

It seems that it doesn't recognize the operators of less than or equal to
nor the Between statement.



Son't even try to use Between in this kind of situation.
Use = and = instead.

I think I would use this kind of criteria:

=Nz(Forms!frmMyForm!txtStartDate,#1/1/1000#) AND

=Forms!frmMyForm!txtEndDate
--
Marsh
MVP [MS Access]

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:36 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.