PC Review


Reply
Thread Tools Rate Thread

Can someone tell me what's wrong with this SQL?

 
 
ThriftyFinanceGirl
Guest
Posts: n/a
 
      21st Jul 2009
Trying to do a DCOUNT to test whether or not there are overlapping dates
before allowing the user to create a new record....

If DCount("taxname", "SELECT TaxRatesBases.TaxID, TaxRatesBases.BusUnit, " & _
"TaxRatesBases.TaxName, Location.City, Location.State,
Location.County, " & _
"TaxRatesBases.TaxEffectiveDate, TaxRatesBases.TaxEndDate "
& _
"FROM Location INNER JOIN TaxRatesBases ON Location.BusUnit
= " & _
"TaxRatesBases.BusUnit;" ,""" & strWhere5 & strWhere2 & " & _
" AND [TaxRatesBases].[TaxEffectiveDate]< " &
Forms![qryWorkWithTax subform]!SetEffDate & " & _
" AND [TaxRatesBases].[TaxEndDate] Is Null OR " & strWhere5
& strWhere2 & " & _
" AND [TaxRatesBases].[TaxEffectiveDate]< " &
[Forms]![qryWorkWithTax subform]!SetEffDate & " & _
" And [TaxRatesBases].[TaxEndDate] > " &
Forms![qryWorkWithTax subform]!SetEffDate & """) > 1 Then
 
Reply With Quote
 
 
 
 
Sylvain Lafontaine
Guest
Posts: n/a
 
      21st Jul 2009
First, take a look at the documentation for the DCount function():

http://www.techonthenet.com/access/f...ain/dcount.php
http://office.microsoft.com/en-us/ac...288171033.aspx

DCount is used for simple counting tasks and you don't put a SELECT
statement in a DCount and you can't count over multiple fields. If you want
to perform a calculation over multiples fields, you'll have to build a full
SELECT statement and execute it with whatever plateform (DAO, ADO, etc.)
you're presently using.

--
Sylvain Lafontaine, ing.
MVP - Windows Live Platform
Email: sylvain2009 sylvainlafontaine com (fill the blanks, no spam please)
Independent consultant and remote programming for Access and SQL-Server
(French)


"ThriftyFinanceGirl" <(E-Mail Removed)> wrote in
message news:C5486B59-1A71-47A9-A15E-(E-Mail Removed)...
> Trying to do a DCOUNT to test whether or not there are overlapping dates
> before allowing the user to create a new record....
>
> If DCount("taxname", "SELECT TaxRatesBases.TaxID, TaxRatesBases.BusUnit, "
> & _
> "TaxRatesBases.TaxName, Location.City, Location.State,
> Location.County, " & _
> "TaxRatesBases.TaxEffectiveDate, TaxRatesBases.TaxEndDate "
> & _
> "FROM Location INNER JOIN TaxRatesBases ON Location.BusUnit
> = " & _
> "TaxRatesBases.BusUnit;" ,""" & strWhere5 & strWhere2 & " &
> _
> " AND [TaxRatesBases].[TaxEffectiveDate]< " &
> Forms![qryWorkWithTax subform]!SetEffDate & " & _
> " AND [TaxRatesBases].[TaxEndDate] Is Null OR " & strWhere5
> & strWhere2 & " & _
> " AND [TaxRatesBases].[TaxEffectiveDate]< " &
> [Forms]![qryWorkWithTax subform]!SetEffDate & " & _
> " And [TaxRatesBases].[TaxEndDate] > " &
> Forms![qryWorkWithTax subform]!SetEffDate & """) > 1 Then



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What do I do wrong [Excuses pushing the wrong key combination earlier] Vsn Microsoft Excel Programming 6 8th Nov 2009 09:12 PM
Insert Calculated Field (wrong Qty*Price = wrong Amount) =?Utf-8?B?RWRtdW5k?= Microsoft Excel Misc 8 4th Oct 2007 12:13 PM
Provide wrong filter with search query, AD returning wrong err cod =?Utf-8?B?ZGFyc2hp?= Microsoft Windows 2000 Active Directory 1 11th Jun 2007 04:44 PM
Oracle Stored Procedure - Wrong Number of Parms Or Wrong DataTypes =?Utf-8?B?SmltIEhlYXZleQ==?= Microsoft ADO .NET 1 8th Aug 2004 01:37 AM
Windows 2000 reports wrong number of CPUs and wrong speed Rogarr Microsoft Windows 2000 1 8th Sep 2003 04:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:08 AM.