473,397 Members | 2,077 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,397 software developers and data experts.

Strange behavior in query window

Seth Schrock
2,965 Expert 2GB
In a query, I'm trying to concatenate customer names together into a single field.
Expand|Select|Wrap|Line Numbers
  1. ([CustFN] & (' '+[CustMI]) & (' '+[CustLN])) AS CustName
When I run this query, only the first name displays. However, if I click inside the field, then the middle initial and last name show up, but just in the one cell. When I click out of it, then that name goes back to just being the first name. I have never seen this before.
Mar 7 '14 #1

✓ answered by Rabbit

You're replacing the ascii result of 0. The ASC function was just to find the character. You need to replace the actual character. Use CHR(0) instead.

29 1220
NeoPa
32,556 Expert Mod 16PB
Is the column wide enough to display the data?
Mar 8 '14 #2
Seth Schrock
2,965 Expert 2GB
More than enough for the combination of all three fields.
Mar 8 '14 #3
GKJR
108 64KB
Is this in a saved query or is it an SQL statement used as source data for an object?
Mar 8 '14 #4
Seth Schrock
2,965 Expert 2GB
This is in a querydef.
Mar 8 '14 #5
NeoPa
32,556 Expert Mod 16PB
Sorry Seth. In that case I've no idea what may be going on.
Mar 8 '14 #6
GKJR
108 64KB
I don't get it either. It seems like the other values are being stored in different columns, but that wouldn't make sense for a querydef. The only time I've seen anything like this is in a control with multiple columns. What happens if you take out the custMI as a test and just concatenate the first and last name without (+)?
Mar 8 '14 #7
NeoPa
32,556 Expert Mod 16PB
Also, check what the actual value of the field is. It may appear the way you say if there are CR or LF characters in the value anywhere. Maybe they are in your code and maybe they are embedded within the field values of the records themselves.

It would explain why you're seeing what you're seeing.
Mar 9 '14 #8
GKJR
108 64KB
What are CR and LF character?
Mar 9 '14 #9
Seth Schrock
2,965 Expert 2GB
CR is Carriage Return and LF is Line Feed, Chr(10) and Chr(13). I'm not sure which one is Chr(10) and Chr(13) as they are almost always together.

Removing the CustMI doesn't change anything, nor does including each field individually. I tried using the Replace() function to remove the Chr(10) and Chr(13) characters, but that didn't change anything. I also tried changing my concatenation characters to all ampersands, but again, there was no change.
Mar 10 '14 #10
zmbd
5,501 Expert Mod 4TB
chr(10) = LF
chr(13) = CR
-
If even one return is longer than your field width then you'll find this happens, and it's a pain to T.S. without the length

What I did in my form was return the length of the string
such as:
Expand|Select|Wrap|Line Numbers
  1. LEN([CustFN] & (' '+[CustMI]) & (' '+[CustLN])) AS CustName 
  2.  
then in the conditional, ">=" field width.
For me, this returned only one record that was 2 charactors too long and that was the issue.
Mar 10 '14 #11
Seth Schrock
2,965 Expert 2GB
Well, every field that has data in it returns a Len() of 16 even if it is only displaying 5 characters. I tried using the Trim() function to take away spaces, but the padding character must not be a space as the Trim() function didn't do anything.
Mar 10 '14 #12
GKJR
108 64KB
Are the text fields in the table set to that length? I always interpreted that setting as the maximum length but is there some way that it automatically designates the length as 16 even if it doesn't use that many characters?
Mar 10 '14 #13
GKJR
108 64KB
Also, if you change the column width in your query to be much wider, does it show the rest of the name with a bunch of spaces in between?
Mar 10 '14 #14
Seth Schrock
2,965 Expert 2GB
I'm using a SQL Server backend that has column level encryption on these fields, which I believe is what is causing the padding. And no, making the query column very wide doesn't show the fields I'm needing.
Mar 10 '14 #15
GKJR
108 64KB
I'm afraid I'm not going to be much help on that if you're using SQL Server, sorry. I just noticed that you have a semi-colon after your Ampersand in the original post. Was that intentional?
Mar 10 '14 #16
GKJR
108 64KB
Sorry forget that. I viewed it wrapped and it put a semi-colon there. When I unwrapped it it was still there...
Mar 10 '14 #17
Seth Schrock
2,965 Expert 2GB
Neither ampersand has a semi-colon after it in the OP. I would be getting an error message if there was.
Mar 10 '14 #18
Rabbit
12,516 Expert Mod 8TB
What's the ASCII value of the padding characters?
Mar 10 '14 #19
Seth Schrock
2,965 Expert 2GB
I don't know how to find that out.
Mar 10 '14 #20
Rabbit
12,516 Expert Mod 8TB
Asc(Right([Field Name], 1))
ASC() if you're using Access, ASCII() if you're using a pass through.
Mar 10 '14 #21
Seth Schrock
2,965 Expert 2GB
It returns a 0. I tried doing a replace on that character, but that didn't change anything on the length.
Mar 10 '14 #22
Rabbit
12,516 Expert Mod 8TB
Can you post the full SQL you are now using?
Mar 10 '14 #23
Seth Schrock
2,965 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. SELECT tblCustomers.CustID_pk
  2. , tblCustomers.LoanID_fk
  3. , ([CustFN] & (' '+[CustMI]) & (' '+[CustLN])) AS CustName
  4. , Asc(Right([CustFN], 1)) As Character
  5. , Len(Replace(CustFN, Asc(Right([CustFN], 1)), '')) AS Length
  6. FROM tblCustomers;
  7.  
Mar 10 '14 #24
Rabbit
12,516 Expert Mod 8TB
You're replacing the ascii result of 0. The ASC function was just to find the character. You need to replace the actual character. Use CHR(0) instead.
Mar 10 '14 #25
Seth Schrock
2,965 Expert 2GB
Well, I'm now on the right track as now most of the names are being returned. I believe that I just need to handle the nulls and then I'll be good to go. Thanks Rabbit.
Mar 10 '14 #26
Rabbit
12,516 Expert Mod 8TB
No problem, good luck on the rest of your project.
Mar 10 '14 #27
NeoPa
32,556 Expert Mod 16PB
Can you confirm that the data was all there as expected but, because it was padded with Chr(0)s it wasn't showing?
Mar 10 '14 #28
Seth Schrock
2,965 Expert 2GB
Unfortunately, I can't confirm that because I was never able to stretch out the cell and see the other data. However, what I ended up with would seem to confirm that because all I ended up doing was a single replace statement on the concatenated data. So the computer seems to say that that data was all there as expected, but I wasn't able to visually verify that.
Mar 10 '14 #29
NeoPa
32,556 Expert Mod 16PB
Cheers. If the following snippet in your SQL caused the data to show then that's confirmation enough for me :
Expand|Select|Wrap|Line Numbers
  1. Replace([CustFN] & (' '+[CustMI]) & (' '+[CustLN]),Chr(0),'')  AS [CustName]
Although the following may be a better solution assuming [CustLN] is guaranteed to be populated whereas the other two are not (which is the usual way of name data) :
Expand|Select|Wrap|Line Numbers
  1. Replace(([CustFN]+' ') & ([CustMI]+' ') & [CustLN],Chr(0),'')  AS [CustName]
Mar 10 '14 #30

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

Similar topics

2
by: Marcus | last post by:
Hello, I recently converted all my existing MyISAM tables to InnoDB tables through phpmyadmin. I noticed some strange behavior whenever I would refresh the screen, as phpmyadmin would report...
1
by: Mei | last post by:
Hi, I'm running ASP under IIS 6 with Tomcat. During the process, Tomcat will forward to an ASP page with some data and those data will be written to MS SQL and display some information in that...
11
by: Marlene Stebbins | last post by:
Something very strange is going on here. I don't know if it's a C problem or an implementation problem. The program reads data from a file and loads it into two arrays. When xy, x, y, *xlist and...
18
by: genc ymeri | last post by:
Hi, I just noticed that while trying to run this code : MessageBox.Show("Hello"); the message box pops up but shows no string/message in it. (expecting the "Hello" string). Even the "OK"...
0
by: Ronen | last post by:
I have a strange behavior with dialog windows postbacks Here is what I doing: 1. Call window.showModalDialog('webForm1.aspx') from script. (I also using <base target="_self">) 2. After the dialog...
2
by: Maileen | last post by:
Hi, I have some strange behavior in my application. Let's say I have 2 buttons and 1 Textbox. 1. when i click on button1, it writes "hello world" in my textbox. i see it. 2. after that, i...
2
by: Daniel | last post by:
Hello Everyone, I am using VS 2002 (VB.NET) and have a MDI application in which the user will open several child windows at the same time. I have included a menu Window, which MDIList property...
1
by: Alexander Inochkin | last post by:
Hi! I found same strange behavior of ASP.NET. It is possible this is the bug. Follow the steps:
0
by: ivb | last post by:
Hi all, I am using DB2 8.1.11.1 on NT with ASP.NET 1.1 When application make connection to database (via ADO.NET), it set "Connection timeout" parameter to 30 seconds. After, when my webpage...
2
by: Nemo | last post by:
I have done append queries before, though not recently, so I may be doing some very simple error to which I am oblivious. I am using the query window. When the query I wanted to do ran into Key...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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
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
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...

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.