473,396 Members | 1,997 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,396 software developers and data experts.

Is there a danger in switching the data type of a field in Access?

I'm working with a very large Access database that has been maintained by my company for many years. There are nuisances that occur due to a field in one of the tables being coded as a text field, when I believe it should be a number field (this will stop the small nuisances from occurring). Is there any danger to the database if this field is changed? This table is a master table that is linked to many queries, forms and reports so I don't want to alter the data type for this field if it could potentially cause errors in any of the other queries, reports or forms down the line.

Is there a reason this field may have been coded as text instead of a number that I could be unaware of? The values in the affected field range from 0 to around 30,000 and are whole numbers only.

I realize this may be an obscure question and may not be easily answered, however, I'd appreciate any feedback.
Aug 27 '14 #1
10 1315
BikeToWork
124 100+
First back up the database and make a copy of the table. Next, check queries using the text field for joins. If you find none, create a new numeric field to hold the converted number value from your text field. If you do find joins based on the text field, they must be joined to another text field or there would be a data mistype error. This could turn out to be difficult, but you'll need to figure out how to join your numeric field to a numeric field in the other table of the query or else change the join field in the other table in the query to a numeric datatype. Next, check to make sure all values in your text field are numeric. Run a query where you use the IsNumeric() function to find any non-numeric values. Then, update your numeric field to CLNG(TextField) after you resolve all non-numeric values in the text field. Finally, rename your text field and rename your numeric field to the previous name of your text field. Good luck.
Aug 27 '14 #2
zmbd
5,501 Expert Mod 4TB
BACK UP THE FILE!
I can not stess that enough.
Because we do not know the schema that your original file was developed under it is hard to say. However, most likely because the default field type is text your original developer simply used the default.

There most likely will need to be adjustments made to your queries. Because the field is text you will have quote marks around the search terms. These will have to be removed for numeric fields.

You will also have to look at table joins... all the other table fields that rely on that "text" form of the numeric will have to be delt with too... and that can be a bear.

There's really only one way to findout what will break...

Once you have a back up... make one more copy. This will be your development copy. So now you have, the production file, the backup file, and the production file.

If this is a split database (you do not indicate this) then make those same backups and copies for each file.

Now take your production copy, put it in an easy to access location on your PC/Network... re-link any linked tables if needed and check to see if it works correctly.

Now make your change.

Test the database, fix any issues, and retest. Once this works as expected you will need to figure out how to impliment them to your production copy.

For forms, reports, and queries you can copy those objects over. For the table you will need to do that change by hand.

let us know how you get a along.


BACK UP
BACK UP!
BACK UP!!!
Aug 27 '14 #3
Is there a quick and easy way to check for joins? There are simply too many queries for me to check through them one by one.
Aug 27 '14 #4
zmbd
5,501 Expert Mod 4TB
For Joins,
Open the file.
For ACC2007/newer>
Ribbon>Database Tools>Relationships>Relationships

For ACC2003, it's in the file menu, same thing.

This will open a window that should show any defined relationships. This however, has nothing to do with your queries.
To find queries that have the field in question TheSmileyCode has written a simple function to help out and can be found in our insights articles... the direct link http://bytes.com/topic/access/insigh...ontrols-string
Please take the time to read thru the article and the comments before using the code. Most questions about it should allready be answered therin.
Aug 27 '14 #5
GKJR
108 64KB
What are the nuisance errors you are getting? I would think your developer made that decision intentionally and you should work through the nuisance errors rather than change the data type. I have chosen to use text fields that hold number values for sorting reasons in some applications- text fields sort alphabetically instead of numerically. They will also hold leading zeros and you can concatenate their value to other string values directly. You may cause a problem that you don't spot right away somewhere down the line. I would suggest that you be absolutely sure you're not making a mistake before proceeding. You may cause yourself a major headache instead of a nuisance error.
Aug 27 '14 #6
zmbd
5,501 Expert Mod 4TB
GKJR has some very valid points.

The warning if issues... hence my very first admonishment... back up and my second admonishment... use a development copy.

GKJR: Sorting: In this case, kw127533, doesn't mention having any alpha charactors in the field and BtW suggestion to check for only numerics will turn up this hazard; thus, the numeric vs alpha sorting is irrelevant unless you want a sort like 1,11,1111,2,22,2222 instead of the expected numeric sort of 1,2,11,22,1111,2222

Formating: Any issues with the formating and string functions are easily delt with requiring very little effort and IMHO rarely a reason to use a Text field for STRICKLY numeric data.
Aug 27 '14 #7
I think you're right, GKJR. I don't think I'm going to mess with this since the database in question is just too important to too many people and is used on a daily basis.

I think this one is over my head. I'm glad I asked before making a potentially huge mistake. Thanks all for your quick responses!!
Aug 28 '14 #8
One more question...Is there a way to change a field's data type through a query? This would allow me to alter the data without affecting other parts of the database.
Aug 28 '14 #9
twinnyfo
3,653 Expert Mod 2GB
kw,

Once you pull a field into a query, you can manipulate the data however you want in an output field. Remember, you are only extracting data with a select query.

You are not really "changing the data type," but you are changing how the data may be displayed. I hope this makes sense.

For example you can pull the text value "20040814", which may look like all numbers--but it is text.

When you grab that text value into your Query, you can change it all around to make it useful:

Expand|Select|Wrap|Line Numbers
  1. =Format(CDate(CInt(Left([TextValue],4)) & "-" & _
  2.       CInt(Mid([TextValue],5,2)) & "-" & _
  3.       CInt(Right([TextValue],2))),"dd mmm yyyy")
Would render: 14 Aug 2004

However, your data type is still text in the underlying table.
Aug 28 '14 #10
Ok, great. Thanks! At least I can fix the errors as they occur in certain objects rather than jeopardize the whole database's functionality. This will do for now. I appreciate everyone's help!!
Aug 28 '14 #11

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

Similar topics

1
by: SD | last post by:
Hi, This is driving me nuts, I have a table that stores notes regarding an operation in an IMAGE data type field in MS SQL Server 2000. I can read and write no problem using Access using the...
4
by: N J | last post by:
Hi, CurrentDb.Execute "Update tblDelayedOrders Set DELAYED = True Where ID = " & Me.txtOrderNumber & ";", dbfailonerror Me.StatusListBox.AddItem "ORDER # " & Me.txtOrderNumber & " MARKED AS...
0
by: elena | last post by:
Hi, All Please, help with conversion I have database (Access) fields like currency and Date/Time - short Date and short Time. How i can convert string to currency and insert value into db field?...
0
by: selacika | last post by:
Hi all; My question is about how to get non-font information part of a field of text data type using an sql sentence. Shortly how to get pure info from a text data type field. Example: Value of...
1
by: ritu raj shriwastaw | last post by:
I am using window xp and php trait(php3.1,mysql4.2).i have one field is of memo data type and I am unable to retrieve data from that memo data type field. what query I should write?
2
by: nduerr | last post by:
I have a table with pdf files stored in an attachment data type field in a 2007 Access File. I would like to run a query that would select a group out of this table (easy part) then send the pdf...
0
by: bkberg05 | last post by:
Hi - I currently use Access 2003 and have documents stored in an OLE data type field. I want be able to write a query that contains various other data elements from the table plus the OLE field and...
2
by: JoeKid09 | last post by:
Hi Guys, I'm working on converting a large table with a field that has numeric values in text data type. When I do the conversion in Access automatically some records don't get converted. The...
1
by: kimsengora | last post by:
Ex. I need to fill in values argument Field1 is text Field2 is image Insert into tbl1 values("'+val1+"','+val2+'") val2 is image like...
1
by: littlemaster | last post by:
I am having table in psql it has one field as integer array data type. From rails application I was not able to insert value in that filed. Example: Need to add multiple userid in the name...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.