Compile Error Help

G

gdaniels

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
 
J

John W. Vinson

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/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top