[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Query with "AND"

Posted on 2003-10-31
3
Medium Priority
?
233 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

656 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