-
I am trying to write an SQL statement and I can't get the syntax right for it to work. Is there a site that I can learn the SQL syntax? Thanks
Here's the Function:
Public Function GetClient(sClientName As String) As String
Dim sSQL As String
Dim sName As String
sSQL = "SELECT * From Customers " & "WHERE Customers.Contact Name = '" & sClientName & "'"
Set rs = MyDb.OpenRecordse (sSQL,dbOpenDynaset)
rs.Close
End Function
[This message has been edited by bontyboy (edited 02-15-2000).]
-
sSQL = "SELECT * From Customers "
sSQL = sSQL & "WHERE Contact Name = '"
sSQL = sSQL & sClientName & "'"
check an make sure there is/isn't a space in contact name field
[This message has been edited by BG (edited 02-15-2000).]
-
Change Contact Name to [Contact Name]
(use brackets for fields with spaces)
SQL tutorial @ http://w3.one.net/~jhoffman/sqltut.htm
-
Try using "LIKE" instead of =
-
That must work.
dim MyDb as Database
dim RS as recordset
set MyDb=OpenDatabase("c:\db.mdb")
sSQL="SELECT * FROM Customers where Contact_Name=' " & sClientName & " ' "
set RS =MyDb.OpenRecordset(sSQL,dbOpenDynaset)
' I'm not shure that SQL allows space in field name ("Contact Name") so use field name like Contact_name or use brackets.
-
Also, here is a great site for a quick overview of SQL and how to use it. Print it out and have it by your computer whenever you are going to be using SQL.
------------------
Ryan