?
Solved

Query with "AND"

Posted on 2003-10-31
3
Medium Priority
?
229 Views
Last Modified: 2010-05-01
I'm trying to write a query in my Visual Basic application (Access as a database) as follow:
strSQL = "SELECT * FROM qryLearnerwithCourses "
strSQL = strSQL & "WHERE (qryLearnerwithCourses.Learner_ID = '"txtlearnerid.Text"') and (qryLearnerwithCourses.WCB_ID = '"companywcb.Text"') "

visual basics doesn't like this statement.  after moving away from that line i get the error: "expected end of statement"  and it changes the color of this code to red.
do you know what i'm doing wrong?
thank you
0
Comment
Question by:mapy
[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
3 Comments
 
LVL 18

Accepted Solution

by:
bobbit31 earned 2000 total points
ID: 9660446
strSQL = strSQL & " WHERE (qryLearnerwithCourses.Learner_ID = '" & txtlearnerid.Text & "') and (qryLearnerwithCourses.WCB_ID = '" & companywcb.Text &"') "
0
 
LVL 29

Expert Comment

by:leonstryker
ID: 9660640
As a note

You should also check the value of you text boxes to make sure the user did not enter any single  or double quotes, since they will break your code.

Leon
0
 

Expert Comment

by:vkgonline
ID: 9669286
Yes, provided solution work. Note one more thing, sometimes user wants to enter a single code as the need of application. To handle it convert single code to double code.

Vinod
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

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…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month9 days, 2 hours left to enroll

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