Solved

Substring??? MID????

Posted on 2002-04-30
13
432 Views
Last Modified: 2008-03-17
I am trying to get this query to work and I am getting this error on this part...


ISNULL((SELECT SUM(dbo_pm30200.DOCAMNT) FROM dbo_PM30200
WHERE SUBSTRING(dbo_pm30200.DOCNUMBR,5,3) = "LDG" and dbo_upr00100.employid = dbo_pm30200.vendorid),0)

It says that it doesn't recognize SUBSTRING().

SUBSTRING
---------
APR-LDG
MAY LDG
OCT/LDG
LDG ACD
FEB LDG 02

(5) Records.


What else could I use instead?
0
Comment
Question by:vbjohn
  • 7
  • 6
13 Comments
 
LVL 12

Expert Comment

by:Paurths
ID: 6981820
mid


mid(string, startposition, length)

cheers
Ricky
0
 
LVL 12

Expert Comment

by:Paurths
ID: 6981826
or,

... where dbo_pm30200.DOCNUMBR like '*LDG*'...
0
 

Author Comment

by:vbjohn
ID: 6981847
Both of those do not work.  Thanks anyways.
0
 
LVL 12

Expert Comment

by:Paurths
ID: 6981882
ok,

the name of your table is 'dbo_pm30200', and the name of the field is 'DOCNUMBR', correct?


does this query work?

SELECT dbo_pm30200.DOCNUMBR
FROM dbo_pm30200
WHERE (((dbo_pm30200.DOCNUMBR) Like "*ldb*"));
0
 
LVL 12

Expert Comment

by:Paurths
ID: 6981884
ldb, should be ldg ofourse...
0
 

Author Comment

by:vbjohn
ID: 6981896
Yes that query works.
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 12

Expert Comment

by:Paurths
ID: 6981916
what is the exact sql-string u are using now?
and what is your goal?
0
 

Author Comment

by:vbjohn
ID: 6981927
Yes that query works.
0
 
LVL 12

Accepted Solution

by:
Paurths earned 50 total points
ID: 6981931
SELECT Sum(dbo_pm30200.DOCAMNT) FROM dbo_pm30200
WHERE (((dbo_pm30200.DOCNUMBR) Like "*ldb*") AND (([dbo_upr00100].[emplyid])=[dbo_pm30200].[vendorid]));
0
 

Author Comment

by:vbjohn
ID: 6983495
It seems like you can not have a query inside of a query.

For example:

SELECT RTRIM(LASTNAME) + ', ' + RTRIM(FRSTNAME)
    + ' ' + RTRIM(MIDLNAME) AS NAME, INACTIVE, ISNULL
        ((SELECT (dbo_UPR00400.MTDWAGES_1 + dbo_UPR00400.MTDWAGES_2+ dbo_UPR00400.MTDWAGES_3 + dbo_UPR00400.MTDWAGES_4+ dbo_UPR00400.MTDWAGES_5 + dbo_UPR00400.MTDWAGES_6+ dbo_UPR00400.MTDWAGES_7 + dbo_UPR00400.MTDWAGES_8+ dbo_UPR00400.MTDWAGES_9 + dbo_UPR00400.MTDWAGES_10+ dbo_UPR00400.MTDWAGES_11 + dbo_UPR00400.MTDWAGES_12) AS Wages
FROM dbo_UPR00400
WHERE dbo_UPR00100.EMPLOYID = dbo_UPR00400.EMPLOYID AND
dbo_UPR00400.PAYTYPE = 5 AND
dbo_UPR00400.PAYRCORD = '1SPSES'), 0) As PDTotal
FROM dbo_UPR00100 INNER JOIN dbo_UPR00400 ON dbo_UPR00400.EMPLOYID = dbo_UPR00100.EMPLOYID
ORDER BY dbo_UPR00100.EMPLOYID;


Is there a way to do it in Access?



John-
0
 

Author Comment

by:vbjohn
ID: 6983815
Using another Question....
0
 
LVL 12

Expert Comment

by:Paurths
ID: 6983934
sure u can use another 'Select...' statement in another

u should have made clear u wanted a 0, or a number with that ISNULL statement...
0
 

Author Comment

by:vbjohn
ID: 6986494
Thanks for the help on the Wildcard thing!
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

895 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now