473,385 Members | 1,397 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Building SQL in Visual Basic

Hello,

I am trying to build an SQL in Visual Basic and need some help with
quotation mark(s).

I have two text fields on a form where the user enters a sales group
range to view records between those sales groups. For example:
Salesgroup 1 through Salesgroup 10. I have written the following piece
of code to get the records between me.salesgroup1 and me.salesgroup2 but
it gives me a compile error and says expected end of statement.

strWhere = strWhere & "([SGRP] = " BETWEEN """" & Me.SalesGroup1 & "'
AND '" Me.SalesGroup2 "') And "

Does anyone see what it is that is wrong with the above statement?

Thanks in advance for any help.

*** Sent via Developersdex http://www.developersdex.com ***
Feb 28 '07 #1
2 1675
On Feb 28, 10:17 am, Faraz Meghani <farazal...@yahoo.comwrote:
Hello,

I am trying to build an SQL in Visual Basic and need some help with
quotation mark(s).

I have two text fields on a form where the user enters a sales group
range to view records between those sales groups. For example:
Salesgroup 1 through Salesgroup 10. I have written the following piece
of code to get the records between me.salesgroup1 and me.salesgroup2 but
it gives me a compile error and says expected end of statement.

strWhere = strWhere & "([SGRP] = " BETWEEN """" & Me.SalesGroup1 & "'
AND '" Me.SalesGroup2 "') And "

Does anyone see what it is that is wrong with the above statement?

Thanks in advance for any help.

*** Sent via Developersdexhttp://www.developersdex.com***
If SalesGroup1 and SalesGroup2 are string values then I think you want
the following:

strWhere = strWhere & "([SGRP] BETWEEN '" & Me.SalesGroup1 & "' AND
'" & Me.SalesGroup2 & "') And "

If SalesGroup1 and SalesGroup2 are numeric values then simply remove
the single quotes.

Bruce

Feb 28 '07 #2
You do understand that, due to the sort characteristics of alphanumeric
data, if your are using the text "Salesgroup 1", "Salesgroup 2", ...
"Salesgroup 10", that Salesgroups 2, 3, 4, 5, 6, 7, and 8 will not be
returned by a WHERE clause of

BETWEEN "Salesgroup 1" and "Salesgroup 10"

That is because the sorted values, in Ascending order, are:

Salesgroup 1
Salesgroup 10
Salesgroup 2
Salesgroup 3
Salesgroup 4
.. . .

This might be contributing to the problem that you are experiencing. That
is, even if you get the quotes corrected on the "BETWEEN", you may not get
the results you expect.

Larry Linson
Microsoft Access MVP

Feb 28 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Marc R. Bertrand | last post by:
Hello, Do some of you know some pretty good books or web tutorials on building databases, if any? By that I mean, when looking at a business, the sound way of choosing the proper fields and the...
1
by: Anthony Biondo Jr. | last post by:
Hi I have some COM+ Objects I wrote in VB6 I have recreated them in VB.net but when I go and try to register the dll I get the error "One or more files do not contain components or type libraries....
2
by: frossberg | last post by:
Hello! I tried to install the Visual Basic.NET Resource Kit (http://msdn.microsoft.com/vbasic/vbrkit/) but obviously something went very wrong and now it sems impossible both to repair and to...
0
by: Herman Jones | last post by:
I'm getting the following error when I build a Class Library project: Embedding manifest... Project : error PRJ0002 : Error result 1 returned from 'C:\WINDOWS\system32\cmd.exe'. It happens with...
0
by: Rul | last post by:
i have to build pdf files from tiff in a visual basic application, so i downloaded http://download.devparadise.com/pdflib-2.01.zip pdflib's 2.01 source to make the visual basic bind, but the vb...
4
by: sqlguy | last post by:
Why do we have to contact MS for a problem that has been with this compiler from at least the beta of VS 20005. I am so sick and tired of the 30 - 40 clicks it takes to dismiss VS when there is a...
97
by: Master Programmer | last post by:
An friend insider told me that VB is to be killled off within 18 months. I guess this makes sence now that C# is here. I believe it and am actualy surprised they ever even included it in VS 2003 in...
4
by: vedrandekovic | last post by:
Hi, I have already install Microsoft visual studio .NET 2003 and MinGw, when I try to build a extension: python my_extension_setup.py build ( or install ) , I get an error: LINK : fatal...
16
by: Lars Uffmann | last post by:
Does anyone have a good suggestion? I am currently using Eclipse Europa with the C-Development Toolkit (plus gnu-toolchain under cygwin) and the Widestudio Native Application Builder plugin. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.