PC Review


Reply
Thread Tools Rate Thread

Compile Error Help

 
 
gdaniels
Guest
Posts: n/a
 
      17th Sep 2010

Hi, need some help here. I'm getting an error that states: "Compile
Error: Expected: (". The code was running OK, then I made some
additions to it. I think the problem is syntax in the line "AND
ASKMFTotal.[CompType]" & strComp & _. When I delete this line it
compiles and runs fine. When I add it in again, I get the same
compile error. Thanks for any help.



Private Sub cmdcity_Click()
Dim db As Database
Dim qdf As QueryDef
Dim strSQL As String
Dim stDocName As String
Dim CriteriaForm As String
Dim CriteriaF As String
Set db = CurrentDb
Set qdf = db.QueryDefs("ASKMFResults-Q")
Dim strHeat As String
Dim strComp As String
Select Case Me.FrameRadHtB.Value
Case 1
strHeat = "='X'"
Case 2
strHeat = "='T'"
Case 3
strHeat = "Like '*'"
End Select

Select Case Me.FrameCompType.Value
Case 1
strComp = "Like 'R'"
Case 2
strComp = "Like 'E'"
Case 3
strComp = "Like 'S'"
Case 4
strComp = "Like '*'"
End Select

strSQL = "SELECT ASKMFTotal.* " & _
"FROM ASKMFTotal " & _
"WHERE ASKMFTotal.City='" & Me.cbocity.Value & "' " & _
"AND ASKMFTotal.State='" & Me.cbostb.Value & "' " & _
"AND ASKMFTotal.[NoUnits]>=" & Me.bminunits.Value & " " &
_
"AND ASKMFTotal.[NoUnits]<=" & Me.bmaxunits.Value & " " &
_
"AND ASKMFTotal.[YrBlt]>=" & Me.bminblt.Value & " " & _
"AND ASKMFTotal.[YrBlt]<=" & Me.bmaxblt.Value & " " & _
"AND ASKMFTotal.LDate>= #" & Me.bminyr.Value & "#" & _
"AND ASKMFTotal.LDate<= #" & Me.bmaxyr.Value & "#" & _
"AND ASKMFTotal.[CompType]" & strComp & _
"AND ASKMFTotal.[HeatPd]" & strHeat & _
"ORDER BY ASKMFTotal.City;"
qdf.SQL = strSQL
 
Reply With Quote
 
 
 
 
John W. Vinson
Guest
Posts: n/a
 
      17th Sep 2010
On Fri, 17 Sep 2010 15:42:00 -0700 (PDT), gdaniels <(E-Mail Removed)>
wrote:

>
>Hi, need some help here. I'm getting an error that states: "Compile
>Error: Expected: (". The code was running OK, then I made some
>additions to it. I think the problem is syntax in the line "AND
>ASKMFTotal.[CompType]" & strComp & _. When I delete this line it
>compiles and runs fine. When I add it in again, I get the same
>compile error. Thanks for any help.


You need the blanks: it's giving you

AND ASKMFTotal.[CompType]LIKE *

and is getting confused. Try

> "AND ASKMFTotal.[CompType] " & strComp & _
> "AND ASKMFTotal.[HeatPd] " & strHeat & _


with a blank after the square bracket.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/For...-US/accessdev/
http://social.answers.microsoft.com/.../en-US/addbuz/
and see also http://www.utteraccess.com
 
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
Export report to Excel, Error message "Compile Error: Argument not mc Microsoft Access External Data 0 16th Jul 2009 09:11 PM
VBAProject name compile error, not defined at compile time Matthew Dodds Microsoft Excel Programming 1 13th Dec 2005 07:17 PM
Compile error. in table-level validation expression. (Error 3320) =?Utf-8?B?RG9ubmE=?= Microsoft Access Forms 4 21st Mar 2005 08:13 PM
error message in Winword. ( Compile error in hidden module: AutoE. =?Utf-8?B?TXkgRXJyb3IgUHJvYmxlbQ==?= Microsoft Access Getting Started 1 4th Oct 2004 02:52 AM
excel 2003 error>> compile error in hidden module: ThisWorkbook clayton Microsoft Excel Misc 4 22nd Jun 2004 02:02 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:10 PM.