Blank Spaces In Data Fields After Copying Data With SQL
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 Replies
ADVERTISEMENT
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 3 Replies
View Related
Jan 19, 2006
I have already asked this question before, but only one person responded, and it was not what I was looking for.
I would like to create a code that takes(copies) each record's data from a field and paste it into another existing field within the same table. I have about 2000 records... Your help will be highly appreciated.
It will have to be a VBA code or macro because I have to alter the strings that are copied before they are pasted into the other field.
View 2 Replies
View Related
Dec 5, 2013
I have a field that has a description of the project I'm working on, which has client information on it. I want to take all 600 of those records and copy them to fields in the same table, so that I can remove the client information, which will allow me to pull whichever of those two I need when I run a query.
View 3 Replies
View Related
Apr 21, 2006
Hi, I'm new here, so I hope I'm posting this in the correct place. I've searched the forum to see if there are any existing threads that might help me, but I've not found anything that does...
(I think this thread ( http://www.access-programmers.co.uk/forums/showthread.php?t=93444&highlight=Copying+data )may be trying to achieve something similar to me, but I'm a beginner and don't really understand it)
I shall stop waffling! I'm not entirely sure that what I'm trying to achieve is possible, I expect it probably is!
Right, I have a form (frmGroupRegister, which contains exactly the same fields as the table it comes from, tblGroupRegister), which consists of three things:
-GroupDate - The date a group took place on. It is my primary key, as no more than one group occurs on a specific date.
-ParentList (A listbox which contains a query showing the ID number, forename and surname of everyone in a table, tblParentDetails)
-ParentsAttending (A blank listbox)
I would like to place buttons in between the ParentList and ParentsAttending, which would allow users to conduct a 'register' of attendance by copying individual/multiple details from ParentList into ParentsAttending (much like you get when choosing which fields to include in a form when using a wizard for example). I would also like them to be able to remove people from ParentsAttending by using a button in case of accidentally adding the wrong person into the ParentsAttending box.
I'm aware that another, probably simpler way of achieving this would be to use a tick-box system, but I feel that visually, the first method would both look better and demonstrate who is present more clearly.
Any help would be much appreciated, but my Access skills are quite basic and things will probably need to be spelled out for me.
I'm using Access 2000 and Windows XP.
Thanks for your help,
Alice :)
View 1 Replies
View Related
May 19, 2015
I have to import a table into a government database. I've got the data lined up in a table and exported to csv. The problem is that the government database doesn't allow empty fields, or the commas created by empty fields. The empty fields are create by criteria that changes with each employee. Is there a way to get rid of them without manually deleting them? I would imagine there is but can't find anything about it or maybe I don't see the forest for the trees? Sample csv below with surplus commas.
Code:
3010,702073771620150200000000000001,3015,IT3(a),3020,A,3025,2015,,,3030,Sabelo,3040,Nkosinathi ,3050,NE,3060,6012125391085,3070,,3075,,3080,19601212,3100,0000000000,3263,55103,3264,ZAR,3125,,3136,0437343012,3138,,3147,
Farm 1317,3149,Vincent,3150,5275,3160,1,3170,20140801,3180,20140925,3200,52.0000,3210,7.0000,3214,PO Box 13092,3216,Vincent,3217,5217,3218,,3247,N,3249,X,3253,,3254,,3262,,3240,0,,,,,,,,,,,
3601,37,3698,37,4001,146,4497,147,4141,3.70,4142,1.85,4149,5.55,4150,02,,,,,,9999
View 14 Replies
View Related
Mar 21, 2013
I designed and used an Access 2003 for some time but I have recently updated to Access 2013 and want to rejig and improve my database. My query is that I need to print invoices from my database, there is a header section with my details, then a section with the customers name and address at the left hand side, and the invoice details such as invoice number, invoice date, PO number, credit terms, etc. at the right hand side. I would like to remove any blank lines from the customers address but to still have the invoice details at the right formatted and spaced correctly. Is there any way of doing this, the canshrink property will not work due to the invoice details which still need to be printed to the right?
View 3 Replies
View Related
Jul 5, 2013
I have a query that I made for about five fields, where the criteria is
Like "*" & [Forms]![DATA SEARCH]![Box] & "*"
Where box is the name of the field that I am searching for.
However, some of the fields in my form are left blank, which makes this refuse to give any results when I try to query it with a form. The other problem that I have is that the fields are bland in different parts of the 1,000 some-odd row table, which was imported from MS Excel.
View 1 Replies
View Related
Sep 5, 2014
I work on a pre-created Access database, and the other day I was working on it, and was trying to export something to Excel to sort it and do some Pivot analysis.
Anyway, I must have pressed something, because now every time I open the database, rather than saying "record 1 of 20463" and showing the data from record 1, it shows "record 1 of 1" and all the data fields are blank. If I go to "Records" and "Show All Records" they'll all come up, but I don't want to have to do that every time, and as I import and export all the time, I'm worried that the next time I try it it'll mess up the years of data I have.
View 10 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
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
Sep 30, 2005
im creating a fault logging databse, i have a form that shows all the "machines" details, (including its previous faults in a subform)
i have another form for inputting new faults.
what i want to be able to do is when you click on the "log new fault" the form will open up with some of the same details as the machine i was just looking at. e.g. it will auto copy over the "machine number" and "machine serial"
thanks
View 4 Replies
View Related
Nov 25, 2004
I am creating a database where I want to have a table that has references to another table.
I have an ID field in both that are linked. I want to be able to on creation of a new record in this new table have it grab the ID field from the other table.
View 1 Replies
View Related
Mar 1, 2005
hi
I am trying to copy the data from one table into another table. I then wanted to update the table where it is copied from. This data i then wanted copied into that table in another row.
Any ideas?
View 1 Replies
View Related
Jan 12, 2007
Hi:
I am looking for some guidance in doing the following:
I have a tableO that contains a list of objects that have associated attributes, specifically a list of system_names (object) and the associated attributes (additional fields in the table) that include port_name, port_direction. Think of each one of the records as a template that will supply data to another table, called the Instance table (tableI). The concept is that the user can populate the template with various objects and associated ports, and direction.
The table cols are;
PK|FK|system_name|port_name|port_direction|
The data for this table is manually entered via an associated form.
At some later time, the user want to make a copy of an object(e.g. a record in tableO) by populating Table I (the instance table). The first few fields of tableI are named identical to tableO. Table I contains additional fields that further refine the template, by adding a object_property field, and a port_direction_property field.
Table I looks like:
PK|FK|system_name|port_name|port_direction|prop1|p rop2
The forms interface allows the user to fill in the fields in the TableI (intance table) directly, or, lets the user scroll through the list of objects in the template table, and chose a template, copy the fields:system_name|port_name|port_direction into the same fields in table I, and then add values to prop1 and prop 2 manually.
I made the combo box control that will list the objects from the object column of the template table (table O) and make the desired selection. I have a radio button adjacent to the combo box that when clicked, will copy the selected record and designated fields from the template object table (tableO), into the same fields of the instance table (table I). The instance table is displayed on an adjacent form.
After the fields are copied to the instance table, the user can type in the data into the additional fields (e.g. prop_1, prop_2), and complete the record.
I do not know how I can do the 'copy' from tableO to table I when the radio button is pushed. I know to allow an action when the radiobutton is 'clicked'. Table O and tableI are not currently related.
Can you provide some guidance?
Thanks a lot for your time
J
View 1 Replies
View Related
Dec 13, 2007
Hi,
I'm looking to include a button on a form that opens a new entry in another table and copies some field entries from the first table into the second table. I tried an append query, but it seems to be unable to be displayed in a form. I just want to copy data from one form to another. Thanks.
View 7 Replies
View Related
Apr 6, 2008
Hello All,
Does anybody know a away of copying access data into other applications without the header row. An example being if you copy access data into excel it includes the header row in the spreadsheet. I often have to copy access data into industrial application software but usually paste into excel first (to get rid of the header rows) then from excel into the application. I would like to eliminate this step if I could but not sure how to copy without the header row.
Regards
Daryl
View 1 Replies
View Related
Dec 1, 2005
Hi,
I have a form on which I have asubform. This form is based on a query.
I would like the user to be able to add/and update information from excel to this form.
When I try to copy from Excel and paste them or try to overwrite the eisting data, I get the following error:
" You cannot add or change a record because a realted record is required in tabel "benchmark".
Can anybody tell me how to fix this?
thank u..
Stacey
View 1 Replies
View Related
Jul 2, 2006
HI all,
i have a form THE OREDER FORM and on it there is a subform that stores a list of codes and corresponding products for a particular order.
Now what happens is that sometimes ORDERS have the same product codes, so what I wish is to see if it is possible in same way or another to copy the data on the subform to create the next record as the previous one, and thus avoiding re-choosing all the products.
any help and ideas will be appreciated thanks
View 2 Replies
View Related
Dec 14, 2006
This is surely just going to be a simple dim statement or code.I have 2 forms, one is plancontrol and the other is contacts. The plancontrolform holds a record of contacts for different forms - the contacts form is merely a seperate form to choose which contacts you want to add. (it was to messy keeping it all on one)The contacts form uses cascading combo boxes to choose a contacts. This all works fine but after a contact has been chosen, i want to (through a command button) add it to a viewable list. Once the user has selected all the contacts they want they can close the contacts form. The names will be automatically entered into the plancontrol form. This is not my normal type of database as it is linked to Otulook, therefore some of the rules i abide by i cannot!!Any ideas? Should i (and how do i) keep adding the names to plancontrol as i go along, or just do it all in one go at the end? p.s. plan control is a continous form.thanksKev
View 2 Replies
View Related
Sep 27, 2005
I have an invoice set in a lovely form using Microsoft Access. Each of the invoice there is an option on the top called Paid, ones I check the paid it will stamp it as paid, how do I make it such as, it will copy the paid ONLY record into a summary cheat, which is a report? It have to be copied into a table of course, but I want to copy from the entire invoice which include
Invoice numer, data, name, addres,s blah blah, all I want to be copied is just the number, the name and the total balance and I want that information only to be copied into the table by clicking the Paid check on the form. My other question, how do I delete THAT PERTICULAR record that was copied from the invoice into the new table? Thanks in advance.
Please if possible? Could you explain it as easy as possible with me with as much as examples and easy to read? I am a little slow, thanks. I thank you all again for your help in advance.
View 1 Replies
View Related
Dec 23, 2006
We have saved image in the database as OLE Object. It is showing “Microsoft Photo Editor 3.0 Photo / Package” in the table. We want to save these pictures as external file in Jpeg format. Please help us to solve this problem.
Thanks in advance
View 1 Replies
View Related
Jan 26, 2007
Does anyone know, when having selected the filepath of a MS Word file in a textbox, how to copy the contents of the Word file and place into a memo field of a table?
View 3 Replies
View Related