What is wrong with this SQL? 
Author Message
 What is wrong with this SQL?

I can't figure out what is wrong with this SQL statement?

maurice Muoneke


Dim dbString, rsName As String
Dim sdB As Database
Dim recSet As Recordset

lakeValue = dbLstLake.BoundText
elevValue = dbLstElev.BoundText

dbString = App.Path + "\Site Selection.MDB"     'define database path
Set sdB = OpenDatabase(dbString) ''define species code list database
rsName = "SELECT * FROM [Type] WHERE [Type]![Lake]= " & lakeValue & " AND
[Type]![Elev]= " & elevValue & ""
Set recSet = sdB.OpenRecordset(rsName, dbOpenDynaset)    'i get a datatype
mismatch expression here
Set datElev.Recordset = recSet

datElev.DatabaseName = dbString
datElev.RecordSource = rsName
datElev.Refresh



Mon, 19 Feb 2001 03:00:00 GMT  
 What is wrong with this SQL?
if the type of a variable is text, in sql you should put it in quotation
mark, " or chr(34)
 rsName = "SELECT * FROM [Type] WHERE [Lake]= '" & lakeValue _
        & "' AND [Elev]= '"  & elevValue & "'"      <<-- notice there is single
quotation mark ' inside
or
 rsName = "SELECT * FROM [Type] WHERE [Lake]= " & chr(34) & lakeValue &
chr(34) _
        & " AND [Elev]= " & chr(34) & elevValue & chr(34)  


Tue, 20 Feb 2001 03:00:00 GMT  
 What is wrong with this SQL?
rsName = "SELECT * FROM [Type] WHERE [Lake]= '" & lakeValue & "' AND
[Elev]= '" & elevValue & "'"

Does this work?

Drac

On Thu, 3 Sep 1998 16:06:17 -0500, "Maurice Muoneke"

Quote:

>I can't figure out what is wrong with this SQL statement?

>maurice Muoneke


>Dim dbString, rsName As String
>Dim sdB As Database
>Dim recSet As Recordset

>lakeValue = dbLstLake.BoundText
>elevValue = dbLstElev.BoundText

>dbString = App.Path + "\Site Selection.MDB"     'define database path
>Set sdB = OpenDatabase(dbString) ''define species code list database
>rsName = "SELECT * FROM [Type] WHERE [Type]![Lake]= " & lakeValue & " AND
>[Type]![Elev]= " & elevValue & ""
>Set recSet = sdB.OpenRecordset(rsName, dbOpenDynaset)    'i get a datatype
>mismatch expression here
>Set datElev.Recordset = recSet

>datElev.DatabaseName = dbString
>datElev.RecordSource = rsName
>datElev.Refresh



Tue, 20 Feb 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. ADO and SQL: what am I doing wrong ?

2. SQL What am I doing wrong ?

3. Recordset: What am I doing wrong?

4. What am I doing wrong??

5. What am I doing wrong?

6. Help with syntax. What am I doing wrong

7. What am I doing wrong?

8. What am I doing wrong?

9. What am I doing wrong?

10. Please tell me what I am doing wrong - DAO parameter Append Query :(

11. What am I doing wrong? -MultiSelect List box

12. Select Case - What am I doing wrong?

 

 
Powered by phpBB® Forum Software