473,395 Members | 1,458 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,395 software developers and data experts.

Problem matching any number in query

TD
I have a query with this expression as one of the fields:

Expr1:
IIf(Len([tblSSPbatch]![Batch_Number])=4,Left([tblSSPbatch.Batch_Number],1),IIf(Len([tblSSPbatch]![Batch_Number])=5,Left([tblSSPbatch.Batch_Number],1),IIf(Len([tblSSPbatch]![Batch_Number])=6,Left([tblSSPbatch.Batch_Number],2))))

This expression extracts the vessel number from the batch number.

In the criteria section under the field above I have this:

IIf([Forms]![frmReports]![cboVesselNumber]="*",Like "*" &
[Forms]![frmReports]![cboVesselNumber] &
"*",[Forms]![frmReports]![cboVesselNumber])

This works if cboVesselNumber returns the numbers 1 thru 12 but if
cboVesselNumber returns "*" ,which represents all vessel numbers, then
the query returns zero records.

I can't figure this one out, help!

Thanks,
TD

Jun 8 '06 #1
3 1359
TD

Anyone?

Jun 8 '06 #2
TD wrote:
Anyone?


Try:

SELECT
IIf(Len([tblSSPbatch]![Batch_Number])=4,Left([tblSSPbatch].[Batch_Number],1),IIf(Len([tblSSPbatch]![Batch_Number])=5,
Left([tblSSPbatch].[Batch_Number],1),
IIf(Len([tblSSPbatch]![Batch_Number])=6,
Left([tblSSPbatch].[Batch_Number],2)))) AS Expr1
FROM tblSSPBatch
WHERE IIf([Forms]![frmReports]![cboVesselNumber]="*",
IIf(Len([tblSSPbatch]![Batch_Number])=4,
Left([tblSSPbatch].[Batch_Number],1),
IIf(Len([tblSSPbatch]![Batch_Number])=5,
Left([tblSSPbatch].[Batch_Number],1),
IIf(Len([tblSSPbatch]![Batch_Number])=6,
Left([tblSSPbatch].[Batch_Number],2)))) Like "*" &
[Forms]![frmReports]![cboVesselNumber] & "*",
IIf(Len([tblSSPbatch]![Batch_Number])=4,
Left([tblSSPbatch].[Batch_Number],1),IIf(Len([tblSSPbatch]![Batch_Number])=5,
Left([tblSSPbatch].[Batch_Number],1),
IIf(Len([tblSSPbatch]![Batch_Number])=6,
Left([tblSSPbatch].[Batch_Number],2)))) =
[Forms]![frmReports]![cboVesselNumber]);

You had something like:
SELECT
X AS Expr1
FROM tblSSPBatch
WHERE X
=IIf([Forms]![frmReports]![cboVesselNumber]="*",
X Like "*" & [Forms]![frmReports]![cboVesselNumber] & "*",
[Forms]![frmReports]![cboVesselNumber]);

I changed it to:
SELECT X AS Expr1
FROM tblSSPBatch
WHERE IIf([Forms]![frmReports]![cboVesselNumber]="*", X Like "*" &
[Forms]![frmReports]![cboVesselNumber] & "*", X =
[Forms]![frmReports]![cboVesselNumber])

I just put the criteria inside the IIf. I didn't make any attempt to
organize this mess.

It seemed to do what you asked for with a few sample records. If that
doesn't work, call the Computer Whisperer.

James A. Fortune
CD********@FortuneJames.com

Jun 9 '06 #3
CD********@FortuneJames.com wrote:
I just put the criteria inside the IIf. I didn't make any attempt to
organize this mess.


Something like Left(Batch_Number, Len(Batch_Number) \ 3) should help
simplify things since 4 \ 3 = 1, 5 \ 3 = 1 and 6 \ 3 = 2. You'll still
need an IIf to catch any other lengths.

James A. Fortune
CD********@FortuneJames.com

Jun 9 '06 #4

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

Similar topics

0
by: Irlan agous | last post by:
Hello all, i have this matching story. What i want to do, is to check the variable $betaling if this is 0 or 1. But the id from the tabel form have to be compared with $persid from the table...
2
by: CharitiesOnline | last post by:
Hello, I have set this script up to add paging to a search results page. Which on the first page works fine. I calculates how many pages there should be depending on the number of results returned...
2
by: david | last post by:
Hi all, I have two tables: workgroups (wg_id, wg_name) workgroups_keywords (wgk_wg_id, wgk_keyword) Each workgroup has an associated list of one or more keywords. What I want do to at...
1
by: David C. Barber | last post by:
I'm trying to determine if any matching records exist on a LIKE query performing a partial match of last names to a remote back-end database in the most efficient manner possible. LAN Traffic...
7
by: Thomas Sourmail | last post by:
Hi, I hope I am missing something simple, but.. here is my problem: I need my program to check the last column of a file, as in : a b c d target ref 0 0 0 0 1 a 1 0 0 0 1.5 b 2 0 0 0 2 c
22
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
2
by: jonathan184 | last post by:
Hi I am having a problme where the results of the sql count is not matching the results of the perl script sql count. The script was working fine up till Wed last week and after that the results...
9
by: HC | last post by:
Hello, all, I started out thinking my problems were elsewhere but as I have worked through this I have isolated my problem, currently, as a difference between MSDE and SQL Express 2005 (I'll just...
4
by: sesling | last post by:
I have two tables that contain identical fields. (Account, Amount, Customer ID). I have a query that joins on those three fields. For the most part when matching records I get a one for one match....
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: 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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.