|
-
Feb 14th, 2000, 08:31 PM
#1
Thread Starter
Lively Member
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).]
-
Feb 15th, 2000, 07:34 AM
#2
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).]
-
Feb 16th, 2000, 12:15 PM
#3
Guru
Change Contact Name to [Contact Name]
(use brackets for fields with spaces)
SQL tutorial @ http://w3.one.net/~jhoffman/sqltut.htm
-
Feb 17th, 2000, 05:32 AM
#4
New Member
Try using "LIKE" instead of =
-
Feb 17th, 2000, 06:21 AM
#5
Lively Member
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.
-
Feb 17th, 2000, 06:53 AM
#6
Hyperactive Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|