PC Review


Reply
Thread Tools Rate Thread

Build whre statement

 
 
=?Utf-8?B?RGF2aWQgTWNLbmlnaHQ=?=
Guest
Posts: n/a
 
      15th Sep 2007
Im having problems with the statement following in my code:

"WHERE (((Scores.Season)>= " & Me.txtSeason.Value & " And (Scores.Season)<="
& Me.txtEndSeason.Value & ") AND ((Format([Scores].[Date],'ww'))<= " &
Me.cmbWeekNo.Value & "));"

It works fine if txtEndSeason.Value is equal to txtSeason.Value but if I
have a range say 1880 and 1889 respectively, I get an error stating "...data
type mismatch in criteria expression.." when I run the code.

Full build query statement:

qdf.SQL = "SELECT Scores.ID, Scores.Date, Scores.Season, Scores.Visitor,
Scores.[Visitor Score], Scores.Home, Scores.[Home Score], Scores.Margin,
Scores.Nuetral, Scores.Location, Scores.Location2, Scores.Line," & _
"IIf(Scores!Date-(Now()-0)>0,1,0) AS [Future Game],
IIf(Scores!Margin=0,0,((Scores!Margin)/(Abs(Scores!Margin)))) AS [Win-Loss],
IIf(Round(((((Scores!Date-12/31/1900)/365.25)-(Int((Scores!Date-12/31/1900)/365.25)))*12),1)>9.3,1," & _
"IIf(Round(((((Scores!Date-12/31/1900)/365.25)-(Int((Scores!Date-12/31/1900)/365.25)))*12),1)<1,1,-1))
AS [September Game],
IIf(Round(((((Scores!Date-12/31/1900)/365.25)-(Int((Scores!Date-12/31/1900)/365.25)))*12),1)>11.2,1," & _
"IIf(Round(((((Scores!Date-12/31/1900)/365.25)-(Int((Scores!Date-12/31/1900)/365.25)))*12),1)<1,1,-1))
AS [Bowl Game], 1+(([Home Score]+10)/([Home Score]+[Visitor Score]+20)) AS
[Percent Margin]," & _
"IIf(Abs([Margin])=0,0,(Log(Abs([Margin])))*([Margin]/(Abs([Margin])))) AS
[Adj Log Margin]," & _
"IIf(Scores!Nuetral=0,Scores!Margin-Coefficients![Home Field Adv
Margin],Scores!Margin) AS [Adjusted Margin],
IIf(Scores!Nuetral=0,[Win-Loss]-Coefficients![Home Field
AdvWin-Loss],[Win-Loss])" & _
"AS [Adjusted Margin Win-Loss], [School Season Division].Division," & _
"[School Season Division_1].Division, [Date] & RTrim(Scores!Home) &
RTrim(Scores!Visitor) AS Game, Format(Scores.Date,'ww') AS Week " & _
"FROM Coefficients, [School Season Division] INNER JOIN ([School Season
Division] AS [School Season Division_1] " & _
"INNER JOIN Scores ON ([School Season Division_1].Season = Scores.Season)
AND ([School Season Division_1].Home = Scores.Home)) " & _
"ON ([School Season Division].Home = Scores.Visitor) AND ([School Season
Division].Season = Scores.Season)" & _
"WHERE (((Scores.Season)>= " & Me.txtSeason.Value & " And (Scores.Season)<="
& Me.txtEndSeason.Value & ") AND ((Format([Scores].[Date],'ww'))<= " &
Me.cmbWeekNo.Value & "));"

--
David McKnight
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      15th Sep 2007
It looks like you are comparing text strings not numbers. for number use >
(greater) and < (less) for strings use Strcomp

Returns a Variant (Integer) indicating the result of a string comparison.

Syntax

StrComp(string1, string2[, compare])

The StrComp function syntax has these named arguments:

Part Description
string1 Required. Any valid string expression.
string2 Required. Any valid string expression.
compare Optional. Specifies the type of string comparison. If the compare
argument is Null, an error occurs. If compare is omitted, the Option Compare
setting determines the type of comparison.


"David McKnight" wrote:

> Im having problems with the statement following in my code:
>
> "WHERE (((Scores.Season)>= " & Me.txtSeason.Value & " And (Scores.Season)<="
> & Me.txtEndSeason.Value & ") AND ((Format([Scores].[Date],'ww'))<= " &
> Me.cmbWeekNo.Value & "));"
>
> It works fine if txtEndSeason.Value is equal to txtSeason.Value but if I
> have a range say 1880 and 1889 respectively, I get an error stating "...data
> type mismatch in criteria expression.." when I run the code.
>
> Full build query statement:
>
> qdf.SQL = "SELECT Scores.ID, Scores.Date, Scores.Season, Scores.Visitor,
> Scores.[Visitor Score], Scores.Home, Scores.[Home Score], Scores.Margin,
> Scores.Nuetral, Scores.Location, Scores.Location2, Scores.Line," & _
> "IIf(Scores!Date-(Now()-0)>0,1,0) AS [Future Game],
> IIf(Scores!Margin=0,0,((Scores!Margin)/(Abs(Scores!Margin)))) AS [Win-Loss],
> IIf(Round(((((Scores!Date-12/31/1900)/365.25)-(Int((Scores!Date-12/31/1900)/365.25)))*12),1)>9.3,1," & _
> "IIf(Round(((((Scores!Date-12/31/1900)/365.25)-(Int((Scores!Date-12/31/1900)/365.25)))*12),1)<1,1,-1))
> AS [September Game],
> IIf(Round(((((Scores!Date-12/31/1900)/365.25)-(Int((Scores!Date-12/31/1900)/365.25)))*12),1)>11.2,1," & _
> "IIf(Round(((((Scores!Date-12/31/1900)/365.25)-(Int((Scores!Date-12/31/1900)/365.25)))*12),1)<1,1,-1))
> AS [Bowl Game], 1+(([Home Score]+10)/([Home Score]+[Visitor Score]+20)) AS
> [Percent Margin]," & _
> "IIf(Abs([Margin])=0,0,(Log(Abs([Margin])))*([Margin]/(Abs([Margin])))) AS
> [Adj Log Margin]," & _
> "IIf(Scores!Nuetral=0,Scores!Margin-Coefficients![Home Field Adv
> Margin],Scores!Margin) AS [Adjusted Margin],
> IIf(Scores!Nuetral=0,[Win-Loss]-Coefficients![Home Field
> AdvWin-Loss],[Win-Loss])" & _
> "AS [Adjusted Margin Win-Loss], [School Season Division].Division," & _
> "[School Season Division_1].Division, [Date] & RTrim(Scores!Home) &
> RTrim(Scores!Visitor) AS Game, Format(Scores.Date,'ww') AS Week " & _
> "FROM Coefficients, [School Season Division] INNER JOIN ([School Season
> Division] AS [School Season Division_1] " & _
> "INNER JOIN Scores ON ([School Season Division_1].Season = Scores.Season)
> AND ([School Season Division_1].Home = Scores.Home)) " & _
> "ON ([School Season Division].Home = Scores.Visitor) AND ([School Season
> Division].Season = Scores.Season)" & _
> "WHERE (((Scores.Season)>= " & Me.txtSeason.Value & " And (Scores.Season)<="
> & Me.txtEndSeason.Value & ") AND ((Format([Scores].[Date],'ww'))<= " &
> Me.cmbWeekNo.Value & "));"
>
> --
> David McKnight

 
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
Trying to build a If statement dlbooks Microsoft Excel Worksheet Functions 3 13th Oct 2009 10:08 PM
Build SQL statement iccsi Microsoft Access Form Coding 2 31st Jul 2009 04:35 PM
whre is normal.dot Rod Microsoft Word Document Management 5 22nd Oct 2007 10:56 AM
whre is my V-Sync? Phim ATI Video Cards 3 29th Dec 2004 10:17 AM
Whre is it? Philocophus Windows XP Help 3 12th Jun 2004 08:31 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:27 PM.