Solved

Query with "AND"

Posted on 2003-10-31
3
227 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 500 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

Independent Software Vendors: 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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

695 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