473,499 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Procedure Name Same as Module Name

20 New Member
Admin: This thread was moved from a hijack question posted in Combining Rows-Opposite of Union. Please do not post new questions in existing threads.

@NeoPa

Created a Bytes account to tell you this work is still helping people in 2019!

This Concat function (the one marked as solution) was exactly what I was looking for. Function worked perfectly yesterday. However, today I'm getting an error "Undefined Function 'Concat' In Expression" with no change in my code. I created a new module and changed Concat to Concat2 and it worked. I'm new to VBA and would love to know how to avoid this in the future.

Also, does this work when using a query or subquery in the FROM clause? For me, this yields no concatenation, but creating a table from the same query and referencing that works. Any advice would be great.
Jan 4 '19 #1
15 651
twinnyfo
3,653 Recognized Expert Moderator Specialist
Barmaximus,

Welcome to Bytes!

However, today I'm getting an error "Undefined Function 'Concat' In Expression" with no change in my code.
Any chance that you named the Module "Concat"? This would cause some ambiguity within the DB.
Jan 4 '19 #2
Barmaximus
20 New Member
@twinnyfo of course I did. Changing the name of the module fixed this. Any thoughts on why it worked fine previously?
Jan 4 '19 #3
twinnyfo
3,653 Recognized Expert Moderator Specialist
You probably tried using it prior to saving the Module's Name.

When you call Concat and you have a Module named Concat and a Procedure with the same name, the DB doesn't know how to properly disambiguate. When you build the procedure, your Module was named "Module1" by default--so there was no issue.

These types of issues have had me scratching my head for hours in the past. Now I know to use better naming conventions. So, I would have saved the Module as "modConcat", which contained a Procedure named "Concat". Some go further and name Functions "fnConcat" to further prevent any disambiguation.

Hope this hepps!

Let us know if there are any other headscratchers you need hepp with!
Jan 4 '19 #4
Barmaximus
20 New Member
Thanks @twinnyfo . Any thoughts on this function not yielding a concatenation when called in a Select query with a sub Select query in the From clause? I'm trying to use the function on data generated from a query. However, it doesn't yield the desired results unless I create a table that is identical to the query output.
Jan 4 '19 #5
twinnyfo
3,653 Recognized Expert Moderator Specialist
My only thought is that the SQL engine gets confused or overwhelmed when going into the subqueries. For example, you can refer to open forms for criteria in your queries, but you can't refer to open forms when the criteria is in a subquery (if I remember my experiences correctly).

What have you been trying? If you post your SQL, we can take a look and see if we can decipher anything.
Jan 4 '19 #6
Barmaximus
20 New Member
Below is my code. The subquery finds all keyword matches from a reference library [Component Library] to [Data - Inventory].Description and returns the keyword found and the associated Type. This yields more than one row per component where multiple matches are found. Works perfectly as a standalone query. When inserted as a subquery, it yields one match per component, no concatenation. However, when I create a table identical to the results of the query, I can achieve the desired concatenation.

Expand|Select|Wrap|Line Numbers
  1. SELECT x.Component, 
  2.        Max(x.Description), 
  3.        Max(Concat(Nz(x.Component), Nz(x.PartType)))
  4. FROM (SELECT [Data - Inventory].Component, 
  5.              [Data - Inventory].Description, 
  6.              [Component Library].Keyword AS [Key], 
  7.              [Component Library].Type AS PartType
  8.       FROM [Component Library] 
  9.       LEFT JOIN [Data - Inventory] 
  10.       ON [Data - Inventory].Description LIKE "*" &  [Component Library].Keyword & "*") 
  11.       AS x
  12. GROUP BY x.Component;
Jan 4 '19 #7
twinnyfo
3,653 Recognized Expert Moderator Specialist
I wonder if SQL just doesn't like using that function with JOINs?
Jan 4 '19 #8
Barmaximus
20 New Member
It's possible. I'm extremely new to SQL. But based on my limited knowledge, I would assume it would complete the entire subquery and return it to the main query in the form of a table regardless of the method used to achieve the data.
Jan 4 '19 #9
twinnyfo
3,653 Recognized Expert Moderator Specialist
I'm sure NeoPa will have an intelligent answer on this one.

When SQL executes subqueries, I don't know if the query runs underneath to its full extent and then JOINs or if the top query executes, and the executes a subquery based upon the JOIN.

I know when I have chosen to use sub-queries (instead of things which are frowned upon, like using a Domain Aggregate Function) that I loose the flexibility of using that query as an updateable query. I've recently tried to eliminate all my DA functions from my queries (which is the "right thing to do") but had to go back because I was using them to update tables.

SQL can be finicky sometimes.
Jan 4 '19 #10
Barmaximus
20 New Member
The end goal of this query is to perform a one time Update/population of a Type field in my [Data - Inventory] table. I have been building it in steps to ease in troubleshooting. I have only been using SQL for a few weeks and am trying to avoid starting bad habits, so any advice is greatly appreciated!
Jan 4 '19 #11
twinnyfo
3,653 Recognized Expert Moderator Specialist
I can tell you right now that using this method will not allow you to use it as an UPDATE query.

Ther eis a part of me that wonders about your subquery design. Will something like this work?

Expand|Select|Wrap|Line Numbers
  1. SELECT [Data - Inventory].Component, 
  2.        [Data - Inventory].Description, 
  3.        Max(Concat(Nz([Data - Inventory].Component), Nz([Component Library].Type))) AS PartTypes
  4. FROM [Component Library] 
  5. LEFT JOIN [Data - Inventory] 
  6. ON [Data - Inventory].Description LIKE "*" &  [Component Library].Keyword & "*" 
  7. GROUP BY [Data - Inventory].Component;
Jan 4 '19 #12
Barmaximus
20 New Member
This works but yields the same result as the non-concatenated result I described previously. I like the idea of this suggestion avoiding the need of a subquery if I can get it to work.
Jan 4 '19 #13
twinnyfo
3,653 Recognized Expert Moderator Specialist
And, as I have been playing with this little function, I can't get the concatenation to work with any type of join. It works fine if there is only one table.

You might have to use VBA to cycle through all your required components and concatenate on the fly and update your table as you go.
Jan 4 '19 #14
twinnyfo
3,653 Recognized Expert Moderator Specialist
We may be a bit off center from this thread. I recommend you begin a new thread and we can work thorugh the specifics if you need.
Jan 4 '19 #15
Barmaximus
20 New Member
Done.
Jan 4 '19 #16

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2682
by: Olivier Vierlinck | last post by:
Hi, I've a python script using somecalls to the abs() built-in function. Now, I have to import a module named 'abs' too... The consequence if that line code like if (abs(a-b) < epsilon:...
2
2172
by: John Bentley | last post by:
I have two tasks that I expect will be straight forward to anyone with reflection skills. 1. To return the the name of an object instance (not type) determined at run time. For example, I...
3
2672
by: Pavils Jurjans | last post by:
Hello, I have bumped upon this problem: I do some client-side form processing with JavaScript, and for this I loop over all the forms in the document. In order to identify them, I read their...
2
1280
by: Casey Hawthorne | last post by:
Is there a way to determine -- when parsing -- if a word contains a builtin name or other imported system module name? Like "iskeyword" determines if a word is a keyword! -- Regards, Casey
5
1420
by: Mike Hoff | last post by:
Hello, I am wondering if it is possible to pass a procedure name to another proc. I have been looking into delegates, but cannot seem to get the code correct. Basically what I have is a proc to...
3
2192
by: Anders Jansson | last post by:
Hi all. I have 2 problems when I try to open and convert an ASP.NET VS 2003 web-applikation in VS 2005. In VS 2003 I have no problems at all! First: One subfolder with will not be converted!...
1
17187
by: alain MONTMORY | last post by:
Hello everybody, I am a newbie to python so I hope I am at the right place to expose my problem..... :-http://www.python.org/doc/2.4.2/ext/pure-embedding.html 5.3 Pure Embedding I download the...
3
1775
by: Michel Vanderbeke | last post by:
Hello, While logging the errors in my program, I want to know in which class, function or procedure they occured. Is it possible to know the name of the class, function and / or procedure in...
13
9150
by: Neil | last post by:
Can I get the name of a procedure from within the procedure? In my error handler, I write the error to an error table. I'd like to write the name of the procedure that's writing the error. But,...
13
3044
by: PhpCool | last post by:
Hi, since sometime I'm stuck in a problem where I want to check or uncheck all the checkboxes. If I'm choosing name for the checkbox array as 'chkbx_ary' then I'm able to check/uncheck all the...
0
7128
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7169
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,...
1
6892
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...
0
7385
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
5467
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,...
0
3096
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
3088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1425
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
661
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.