473,491 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Simple list box

law
When I start unselecting in a list box, when I deselect the last one,
it produces the following error: Run time error 5, and this is
highlighted:

strSQL = strSQL & "WHERE tblProduct.Product IN (" & Left(strTemp,
Len(strTemp) - 2) & ");"

any ideas?

Nov 13 '05 #1
9 1316
law
should be

strSQL = strSQL & "WHERE tblProduct.Product ID (" & Left(strTemp,
Len(strTemp) - 2) & ");"

Nov 13 '05 #2
law

law wrote:
should be

strSQL = strSQL & "WHERE tblProduct.Product ID IN(" & Left(strTemp,
Len(strTemp) - 2) & ");"


Nov 13 '05 #3
law

law wrote:
should be

strSQL = strSQL & "WHERE tblProduct.Product ID IN(" & Left(strTemp,
Len(strTemp) - 2) & ");"


Nov 13 '05 #4
You are trying to remove two characters from a zero-length string. You
need to test if the strTemp variable is empty, if not, perform your
trim, if it is do something else.

Nov 13 '05 #5
law
Thanks for the response, but I'm not sure how to do this.

Nov 13 '05 #6
law
When I set it to -0 it appears to work. Is this safe?

Nov 13 '05 #7
change the line you posted to something like...

if strTemp = "" then
'***do what you want here is strTemp is empty
else
strSQL = strSQL & "WHERE [tblProduct].[Product ID (" &
Left(strTemp, Len(strTemp) - 2) & ")];"
end if

you need to decide what to do if the string is empty... also note the
square brackets i've put in there as it looks like you are trying to
generate a field name on the fly and as such you've made it include
spaces so it needs square brackets round the whole thing...

if you meant to test the value in [tblProduct].[Product ID] then you
missed out an = sing such as...

strSQL = strSQL & "WHERE [tblProduct].[Product ID] = (" & Left(strTemp,
Len(strTemp) - 2) & ");"

as you can see the square brackets are still needed for the Product ID
field name...

does that help?

DK

Nov 13 '05 #8
What sbout if the string is "a" ?

You should test like this

if Len(strTemp) < 2 then
'***do what you want here is strTemp is empty
else
strSQL = strSQL & "WHERE [tblProduct].[Product ID (" & Left(strTemp,
Len(strTemp) - 2) & ")];"
end if
--
Terry Kreft
MVP Microsoft Access
"dkintheuk" <rm*******@firenet.uk.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
change the line you posted to something like...

if strTemp = "" then
'***do what you want here is strTemp is empty
else
strSQL = strSQL & "WHERE [tblProduct].[Product ID (" &
Left(strTemp, Len(strTemp) - 2) & ")];"
end if

you need to decide what to do if the string is empty... also note the
square brackets i've put in there as it looks like you are trying to
generate a field name on the fly and as such you've made it include
spaces so it needs square brackets round the whole thing...

if you meant to test the value in [tblProduct].[Product ID] then you
missed out an = sing such as...

strSQL = strSQL & "WHERE [tblProduct].[Product ID] = (" & Left(strTemp,
Len(strTemp) - 2) & ");"

as you can see the square brackets are still needed for the Product ID
field name...

does that help?

DK

Nov 13 '05 #9
ah yes obvious when you say it like that...

Nov 13 '05 #10

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

Similar topics

10
1866
by: george young | last post by:
For each run of my app, I have a known set of (<100) wafer names. Names are sometimes simply integers, sometimes a short string, and sometimes a short string followed by an integer, e.g.: 5, 6,...
3
3656
by: Patchwork | last post by:
Hi Everyone, Please take a look at the following (simple and fun) program: //////////////////////////////////////////////////////////////////////////// ///////////// // Monster Munch, example...
13
5707
by: Michael B Allen | last post by:
Hi, I've tried to write the *simplest* memory allocator possible. I think it would be useful in many cases such as allocating memory on stack as a poor man's garbage collection perhaps. I was...
13
4093
by: na1paj | last post by:
here's a simple linked list program. the DeleteNode function is producing an infinit loop i think, but i can't figure out where.. #include <stdio.h> typedef struct { char *str; //str is a...
6
1381
by: Robert W. | last post by:
I have a situation where I have pairs of strings that I want to put into an ArrayList and then later pull out of it. To keep things simple I tried this to put them in: arrayList.Add(new object...
30
1785
by: Brian Elmegaard | last post by:
Hi, I am struggling to understand how to really appreciate object orientation. I guess these are FAQ's but I have not been able to find the answers. Maybe my problem is that my style and...
10
1759
by: =?utf-8?B?5Lq66KiA6JC95pel5piv5aSp5rav77yM5pyb5p6B | last post by:
Is there a simple function to generate a list like ? The range() just can generate the numeric list.
3
3246
by: rogynskyy | last post by:
Hi guys, I'm running MSDE 2000 A on Win XP I've got a database with several tables, all of the tables display data in query manager. I wrote this simple query: Select
4
1891
by: phe2003 | last post by:
Hi All, I've been testing some extremely simple code about a linked list. What I keep doing is actually writing some parts of a linked list and testing them. Below are my codes:...
2
3502
by: nicholas08 | last post by:
I am new to programming and trying to work on a simple console app. I am making a simple Library Management system where the user/admin can manage members and item. Attaching the menu so it's clear...
0
7157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7364
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5452
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4886
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
3087
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1397
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
282
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.