How to add trailing spaces to a text field (1 Viewer)

cpampas

Registered User.
Local time
Today, 06:34
Joined
Jul 23, 2012
Messages
218
Hello,
I appreciate your your help on this :
I have a table that looks like the following :

maqIddescMaq
1komatsu PC 30
3komatsu PC 30 MR
4komatsu PC 300
5komatsu PC 300 8
6komatsu PC 301
8komatsu PC 130
9komatsu TC 31 KL
10komatsu PC 33
11komatsu PC 30 MR 3

From a previous post I got the idea to build a query search string to find all the records for the machine Komatsu PC 30, anyway this machine can be entered with full or partial description, therefor I want to retrieve records number 1 , 3 , and 11

the query works great except for the last space ( note that there are spaces before and after the search variables ( '* pc *') and also ('* 30 *')
the problem i guess is that there are no stored trailing spaces on text fields, so that the query only finds records with ID number 3, and number 11, but misses, number 1 ( does not find a trailing space )

Code:
SELECT tblMaq.maqId, tblMaq.descMaq
FROM tblMaq
WHERE (((tblMaq.descMaq) Like 'komatsu *' And (tblMaq.descMaq) Like '* pc *' And (tblMaq.descMaq) Like '* 30 *'));

Is there a way to add a trailing space to all the records in my table ? or is there something I should change in my sql search string
Thanks
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 21:34
Joined
May 7, 2009
Messages
19,237
You add but access will remove it
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 21:34
Joined
May 7, 2009
Messages
19,237
You can only add to your query:

SELECT tblMaq.maqId, tblMaq.descMaq
FROM tblMaq
WHERE (((' ' & tblMaq.descMaq & ' ') Like '* komatsu *' And (tblMaq.descMaq) Like '* pc *' And (tblMaq.descMaq) Like '* 30 *'));
 

Gasman

Enthusiastic Amateur
Local time
Today, 14:34
Joined
Sep 21, 2011
Messages
14,269
Can you try?
Code:
SELECT tblMaq.maqId, tblMaq.descMaq
FROM tblMaq
WHERE (((tblMaq.descMaq & ' ') Like 'komatsu *' And (tblMaq.descMaq) Like '* pc *' And (tblMaq.descMaq) Like '* 30 *'));
 

cpampas

Registered User.
Local time
Today, 06:34
Joined
Jul 23, 2012
Messages
218
Thank you so much, it worked great :

Code:
SELECT tblMaq.maqId, tblMaq.descMaq
FROM tblMaq
WHERE ((([tblMaq].[descMaq] & ' ') Like 'komatsu *' And ([tblMaq].[descMaq] & ' ') Like '* pc *' And ([tblMaq].[descMaq] & ' ') Like '* 30 *'));
 

Mike Krailo

Well-known member
Local time
Today, 09:34
Joined
Mar 28, 2020
Messages
1,044
I had similar situation in my part tracking database. Due to the nature of differences in part names, I could not always find all the similar spare parts that were compatible and had different part numbers. The solution was to create another field in the table called PartGroup. This allowed me to force certain groups of parts together by assigning a group number. That completely solved the issue.

That may be something for you to consider and I hope that makes sense.
 

Users who are viewing this thread

Top Bottom