?
Solved

SQL Qestion

Posted on 1998-07-16
4
Medium Priority
?
205 Views
Last Modified: 2010-05-03
I would like to make an sql request (With an access databse) witch contain two compare operators. For example, i want the request to return only the records wtich contain the correct CustomerID AND the correct DateOrder. Following is the code i tried, but it doesn't work. Could anyone say me if it is possible to code it, and how do it ?

Dim MyDb as Database, ResultRequest as Recordset, CustID as Long
Set MyDb = OpenDatabase (MyDatabase)

Set ResultRequest = MyDb.OpenRecordset ( "Select * From [Order] " & "Where [OrderDate] = #" & Calendar1.value & "#" & "AND" & " [CustomerID] = #" & CustID & "#")

Where CustID come from another request of another table.
The system display me an error when trying to execute this code.

I hope someone know the correct answer.
Thank you in advance

BEST REGARDS
0
Comment
Question by:VB041898
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
shagnasty earned 200 total points
ID: 1465950
Should be:

If the CustID field is a string:

Set ResultRequest = MyDb.OpenRecordset ( "Select * From [Order] " & "Where [OrderDate] = #" & Calendar1.value & "#" & "AND" & " [CustomerID] = " & chr(34) & CustID & chr(34))

If it's numerical:

Set ResultRequest = MyDb.OpenRecordset ( "Select * From [Order] " & "Where [OrderDate] = #" & Calendar1.value & "#" & "AND" & " [CustomerID] = " & CustID)

Enclosing it in '#' pair means your specifying a date
0
 

Author Comment

by:VB041898
ID: 1465951
Thank you for your correct answer.
Could you say me where can i find all different syntax for SQL, witch all diffrents type of data.

BEST REGARDS
0
 
LVL 1

Expert Comment

by:shagnasty
ID: 1465952
VB5's online help has most of it (It's Jet specific, but should get you started).  Another good place to start is to use VisData (one of the sample apps that comes with VB5) to build your queries and statements.  Access too has a very good Query builder.  Other than that, your local library of bookshop should be able to point you in the right direction.
0
 

Author Comment

by:VB041898
ID: 1465953
Thank you for your answer

BEST REGARDS
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question