Blank Spaces After Data In Field Is Causing Problems
Aug 30, 2006
Hi Folks,
I am creating an IF CASE statement in SQL that basically takes the 2 last characters in a field and if they happen to be 'HX' then a special rate is used to calculate the cost whereas if their is no 'HX' as the last 2 characters of the field then a different rate is applied.
(Right([BOARD SPEC DATA],2)) has always worked flawlessly in SQL to render similar solutions. However, unfortunetly the weekly extract that comes into us permits for massive amounts of blank but real spaces after the data in [BOARD SPEC DATA] field so what ends up happening is that (Right([BOARD SPEC DATA],2)) yields a (SPACE SPACE) value even thou many of these values should be 'HX' as they are the last 2 real non-space values at the end of the field.
If there any easy way to fix this keeping in mind that this is how we get the extract everyweek so a search/replace on spaces won't work ... is there any way I can use a Right command but ignore spaces so that it simply renders the 2 real characters at the end of the field as oppossed to blank spaces?
Any help is greatly appreciated.
Thank you very much,
Joe
View Replies
ADVERTISEMENT
Apr 14, 2007
Hello there, I'm having a problem very much like the one described by this user (http://www.access-programmers.co.uk/forums/showthread.php?t=113742&highlight=SQL+blank+spaces) where an SQL statement I am using to read data from one table and copy it to another is filling the remaining field space with blanks.
I didn't notice until a VBA module I worked on later on which was to read data from the new table and copy the selected record into a form said it could not find the records. The code:
Do Until blnFound = True Or rs.EOF
'DEBUG: answer = MsgBox("ok", vbYesNo)
'DEBUG: MsgBox rs("Account Name")
If rs("Account Name") = strAName Then
MsgBox "DEBUG: FOUND " & rs("Account Name")
blnFound = True
End If
rs.MoveNext
Loop
The record selector just goes straight to EOF because rs("Account Name") never matches strAName (as strAname has all those damned spaces after the useful data).
I wondered if perhaps there was some way to use the code in the other thread to read the length of useful data and then chop off the garbage spaces afterwards, but I'm worried it would be incredibly slow when running through the thousands of records. Also, the field has legitimate spaces in between words (most of the account names are two or three words in length).
The SQL statement responsible is as follows:
strASQL(i) = "INSERT INTO " & strTableName & "([CAccount No], [Short Name], " & _
"[Account Name], [Telephone], [Fax], [Contact Name], " & _
"[Mail address1], [Mail address2], [Mail address3], [Mail address4], " & _
"[Analysis1], [Analysis2], [Analysis3])" & _
" SELECT [CAccount No], [Short Name], " & _
"[Account Name], [Telephone], [Fax], [Contact Name], " & _
"[Mail address1], [Mail address2], [Mail address3], [Mail address4], " & _
"[Analysis1], [Analysis2], [Analysis3] " & _
"FROM tblCustomer WHERE [" & strField(i) & "] LIKE '" & strValue(i) & "';"
strASQL, strField and strValue are arrays and this SQL statement runs in a loop, as this is part of a search form for multiple possible entries. It all works fine except it always adds those damned spaces :D
Any suggestions?? Cheers.
View 12 Replies
View Related
Nov 28, 2005
Hello,
I have the following SQL query that runs perfectly. Now I need to put some blank spaces in between for the first expresion (EXPR1). At the moment, as you can see, brings me the 4 fields together.
I have tried using + ' ' + and + " " + but it won't let me as it says that the syntax is Incorrect. What should I use to get spaces?
Thank you!
**********
SET @SQL = 'SELECT dbo.brnch.addr + dbo.brnch.suburb + dbo.brnch.state + dbo.brnch.PIN AS EXPR1, dbo.individuals.posit, dbo.individuals.phn, dbo.company.name
FROM dbo.company INNER JOIN
dbo.brnch ON dbo.company.ID = dbo.brnch.com_ID INNER JOIN
dbo.individuals ON dbo.brnch.br_ID = dbo.individuals.br_ID INNER JOIN
WHERE dbo.brnch.country in (' + @OrderList + ') '
EXEC(@SQL)
View 1 Replies
View Related
Feb 26, 2008
My database:
*TblNames
-NameId
-FirstName
-LastName
-UnitID
-AreaID
-RoomID
*TblUnitID (this table doesn't matter)
*TblAreaID (this table doesn't matter)
*TblRoomId
-RoomID
-RoomLabel
I hope you can follow me fine up to this point.
"think of this database as a hotel"
I need a report that looks like:
LastName FirstName Area RoomLabel
name1 name1 B 1
name2 name2 B 2
[empty] [empty] B 3
name3 name3 B 4
As you see not all the rooms are occupied therefor where you see [empty] a blank space must appear or something like [empty] so it indicates that the room is empty.
My problem is that when i do my query it will only show data that has all the fields requested for instance if I know the last name of a client but i don't know their first name, the query will not show this field. even tho there is a client using a room. I don't know how to explain my problem any better. any suggestions?
View 6 Replies
View Related
Mar 10, 2015
I have a listbox in my database to show the items filtered from comboboxes. But, I could see several blank spaces on the right most part whenever I scroll my database on the right side. how to delete those blank spaces? by the way, i have correct/exact column count already.
View 11 Replies
View Related
Mar 21, 2014
I have the follwing three quantities: category, month and value.so I would like a report to place each value in the corresponding row (category) and column (month).using a cross tab query this is quite easy, and I also managed with a simple query, by placing 12 textboxes in the report and using the iif instruction (iif month-jan,value,null and so on for each month).
now the problem arises when i have two values for the same category but in different months. In this case, the report will place the last value in the line below the previous, leaving a blank space.I'll upload an example asap, in the meantime i try to explain it here below:
.......jan..feb..mar..
cat1 10
cat2 30
View 1 Replies
View Related
Jul 31, 2005
Hi,
I have a query with a field defined in the query as follows:
Next Bill Date:
IIf(IsNull([dtmLastBillDate]),
DateSerial(Year([dtmDateRecd]),Month([dtmDateRecd])+1,15),
DateSerial(Year([dtmLastBillDate]),Month([dtmLastBillDate])+[lngNumMonths],15))
I can't seem to set any criteria for this field without getting an error:
'Data Type Mismatch in Criteria Expression'
Examples of criteria that I've tried:
=#1/1/2005#
>#1/1/2005#
=Date()
Year([Next Bill Date]) = Year(Now())
All of the above generate that same error.
{I've seen many pages/posts regarding 'data type mismatch' but none seem to relate directly to this situation.}
I could use some help, fast!
Thanks in advance,
David
View 1 Replies
View Related
Aug 29, 2006
I've got a database with a field PKGNum, that was typically a three digit number, that used to be the primary tracking number for each project. You could have the same package number for multiple customers. About two years ago they began to use what they now call a PMIS number which is a unique number assigned for each project. So I have a seperate field in my database to track that.
I use a query to select information from my database to generate labels for my files. What I want to be able to do is have the system understand that if the field PMIS is blank, for a given record, to give me the PKGNum instead, so that the correct color coded value will print out on the labels. What I've been doing is having folks doing the data entry put the package number into the PMIS field if it's an old file, essentially repeating the value, so that I can pull the report using just the PMIS field for the color coded.
However, I would prefer to not have them have to enter duplicate information. Is there a way to tell the system when it's running the query, if PMIS is blank temporarily fill in the field with the value from PKGNum?
Any and all assistance is greatly appreciated.
View 1 Replies
View Related
Mar 18, 2013
I am creating a report that contains name andd birthdate on one line. I need to have up to seven lines in the report for some groups, but do not want to leave blank lines where no names exist. I am working in 2010 and have read about canshrink in 2007, is this approach availabel in 2010 and for date as well as text?
View 1 Replies
View Related
Jun 19, 2013
I have a form, combo box selection, when i make a selection, all the info is good on all my tabs, which holds the subform.My issue is, on one of the subform, it's a data entry form, where I want it to be on a new record page. instead it list all records. I want my users to see a blank page, but have one field populated. is this possible?
1) blank data entry page, but with a populated field?When a CU Name is selected,I want the (Enter Note) tab to go to a data entry or last page or new page.I have tried putting it to data entry form, but the CU Number will not populate.
View 1 Replies
View Related
Feb 26, 2015
The DolphinBatchNo has number data type but the following sql statement doesn't capture the ight records. it doesn't check id dolphinBatchNo is blank.
Code:
strsql="select * from `MasterTBL` where PolicyNumber>=" & TxtFPolNo & " and PolicyNumber<=" & TxtLPolNo & " and PolicyStatus='Live' and DolphinBatchNo is null order by PolicyNumber"
View 2 Replies
View Related
Aug 2, 2006
I have a database with a series of fields, all set to a String datatype, that I want to be able to fill and then use with MS Word as a mail merge data source. This function lets you query a MS Access db and use the results to fill in predefined spots attached to the various data values in the table. This is great for my needs however a large percentage of times that I have a dash in the value being queried it does not return any results. For example, 01-01 would return no entry found even though I can clearly see it in the database, however it would work fine if I queried for 0101 or any other value in the given field.
Basically I'm trying to figure out why dashes would cause problems. They are obviously fine for being stored in the access database and don't cause any troubles until they are queried for, also retrieving data containing dashes is fine so long as that value is not the one being queried for.
I basically can't avoid the dashes in the data for this setup and as such hopefully can figure out why this happens and how to get around it. Thanks for any help offered.
View 1 Replies
View Related
May 21, 2014
I think I have just finished designing my database and I tried to test it and I couldn't enter any new records as it says "Can't enter data into blank field on "one" side of outer join" whenever I try and enter info and I don't know much SQL to work out what has happened. It probably causes this too but I also cannot select check boxes.
The form where I try and enter the info is called Crisis_support_workers v3. I have attached my database so you can look at what I have done.
View 1 Replies
View Related
Jun 28, 2005
I have a field in a database that needs the data entered without any spaces and I'm trying to figure out how to set either the validation rules or the masks so that the system will either automatically delete any spaces or warn the user not to enter them.
My preference would be for them to automatically be deleted.
Any ideas, suggestions?
I can figure out how to make either all numbers or all letters, but the data is both so that doesn't work.
Thanks, in advance, for your help.
Charis
View 4 Replies
View Related
Jul 3, 2014
My parameters are linked to a form and say:
[Forms]![FormName]![Field] or [Forms]![FormName]![Field] Is Null
Ordinarily this works fine in returning either the selected value or all values if left null.
I need to pull in data from a Crosstab query, which means setting my parameter labels to [Forms]![FormName]![Field].
The problem is that setting the parameter labels is conflicting with pulling all records if the form dropdown is left null.
If I keep my parameters simple and just say [Forms]![FormName]![Field] then the query works with the crosstab data, but I can't do that. I need to show any records if the dropdown is left null.
The crosstab data isn't specifically the problem but needing to set the parameter names seems to be
I think I may have found a workaround by labeling the column headings in the crosstab, which means I don't have to assign parameter labels
It would still be good to know if there's a way of making it work with the parameter labels but this will do for now...
View 7 Replies
View Related
Sep 28, 2006
I have a table that for some reason when I imported the data, placed some spaces before about 75% of the numbers in only one column. I need these numbers to be exactly the same as in another table because I use this number to compare to records and import other data depending on the corresponding numbers.
I tried doing a find and replace, but for some reason it doesn't find the spaces to replace. If I type in the space and the number, then in the replace with type only the number, it works. But I cannot do that since there are literally 10's of thousands of different numbers.
Someone mentioned a "LTRIM" command. Does this work within Access and if so, how does it work?
Thanks,
David
View 3 Replies
View Related
Jun 28, 2006
We have a table with approx 2m records. Just three fields:
Key (primary)
Postcode
Postcode reference
The problem is with the postcodes. Many of these have a double space in them such as this DE13 7EL but we need DE13 7EL.
Find and Replace runs into a problem because of the number of records.
An update query seems obvious but we can't figure out what to put in Update to as this appears to return the literal value.
We are not VBA programmers so that isn't really an option for us.
How can we strip out that extra space?
View 6 Replies
View Related
Dec 7, 2006
Hi
I have a table with postcodes (1.6M rows) that have had all the spaces removed. I want to match another table to it and ordinarily would have removed the spaces from the postcodes in that but I think because of the vol (2.5M rows) Access is reluctant (it either crashes or only updates a few thousand).
A better way would be to reformat the postcode using some SQL or VBA code. The trouble is the postcodes are different numbers of characters and the space would either need to be after the 3rd when there are 6 characters or after the 4th when there are 7 characters.
eg PO121DL becomes PO12 1DL
PO91UL becomes PO9 1UL
I can concatenate fields and count characters but am unsure as to the best way to approach this in terms of coding and structure? Using Access 2002.
Any thoughts/tips etc would be appreciated thanks
View 2 Replies
View Related
Nov 2, 2007
I have an imported file coming from another department and the one of the field names I need to use has spaces. I have tried " " and [] but they don't work. What is the proper syntax for this?
origfield = rst.Fields("FVH PLAN")
Thanks.
View 1 Replies
View Related
Jun 16, 2015
I have a query with multiple fields that is being run off of 3 parameters (linked for selection in a form). The problem is, I wanted to enable a select all feature, so I included a "Or ... Is Null" part in my criteria section, so that when nothing is selected, the query/report returns all records.
Okay so the problem is whenever I run the query with nothing selected for the parameter and then return to design view for the query, a new field has been created in the query design, titled with the expression I use to pull the parameter value from the form. This is frustrating because then that is causing errors in another report I run that pulls values from that query.
View 1 Replies
View Related
Apr 16, 2007
Hi all,
I have an Access DB with hundres of queries and reports, now I have to use an external DB (Oracle) and export data keeping the rest, no problem with that, I have added linked tables through odbc and works fine.
My problem is that some of the tables have field names with spaces, and Oracle doesn't admit them. Does anybody knows how to solve it without having to modify all the queries, etc?, I've been thinking about aliases or views over the linked table but I haven't found a way to create these.
Any help?
Thanks
View 2 Replies
View Related
Apr 20, 2006
I need help. I'm trying to do an update query to delete extra spaces in a field
I want to Change 1234[space][space][space]Elm[space][space] St.
to
1234[space]Elm[space]St.
Thanks,
Vern
View 3 Replies
View Related
Jun 9, 2015
I'm trying to improve the dialer that i place on microsoft access forms. basically there's a command button that dials the number that is in a text box, but we have a new job that's just come in that requires numbers to be copied and pasted into the text box. these numbers have a space between the dialing code and the telephone number and i need to make the dialer check for a space and remove it before dialing.
Here's the code for the dialing buttons:-
Private Sub cmd_Dial_Click()
On Error GoTo Err_cmd_dial_Click
CT.MakeCall "8" & txt_telephone.Value & "#", "", False, "", "", False
[code]...
View 5 Replies
View Related
Mar 25, 2014
GOAL - I would like to have one text box where I enter a sentence
txtKeywords: Access Is For Smart People Smarter Than I
I would like to create a button when clicked moves txtKeywords into another textbox [txtKeywordscombined] field and removes the spaces between the words and adds hyphens
txtKeywordscombined: Access-Is-For-Smart-People-Smarter-Than-I
Would I use the 'Replace' command in even procedures to do this? Another way? Example?
View 1 Replies
View Related
Feb 18, 2007
Hi all
I have a numeric field in a form which initially is set to 0. When the user clicks or tabs to this field, it is blanked out in the got focus event by setting the field to "". This works great. Now, if the user exits the field by clicking elsewhere or tabing out of it, without entering a value, I would like the 0 value to be inserted again. I have tried many things to make this work without any success. Is there someone who knows the right way to do this?
Thanks in advance
View 2 Replies
View Related
Jul 6, 2006
I am building a query for a report - I want to concatenate several fields, but if one of them is blank I don't want it added to the concatenation.
Example: LastName= Kamp
FirstName= Jay
SpouseFirstName = ""
It is ok if the SpouseFirstName is not null
Kamp, Jay & Jill
This is what I get when SpouseFirstName="": Kamp, Jay &
What I want to see when SpouseFirstName="": Kamp, Jay
SELECT Inventory.Code, Inventory.MLS, Inventory.Pin, Inventory.LockBox, Inventory.Vacant, concatenate Code: Original - concatenate Code [LastName] & ", " & [FirstName] & " & " & [SpouseFirstName] AS Expr1, [LastName] & ", " & [FirstName] & " & " & [SpouseFirstName] AS Expr1, Inventory.CompanyName, Inventory.Phone, Inventory.Phone2, Inventory.Cell, Inventory.OfficePhone, Inventory.Ext, Inventory.Fax, Inventory.PropertyDesc, Inventory.Address, Inventory.City, Inventory.State, Inventory.Zip, Inventory.email, Inventory.SellerAddress, Inventory.SellerCity, Inventory.SellerState, Inventory.SellerZip, Inventory.TPUser, Inventory.TPPwd, Inventory.Expire, Inventory.ListPrice, Inventory.OriginalListPrice, Inventory.SoldPrice, Inventory.CloseDate, Inventory.Offer, Inventory.LastName
FROM Inventory;
View 2 Replies
View Related