How do I change a fields datatype in a table in code.
I want to change 1 field from text to number (DbLong)
Thanks,
Scott
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Fields data type (Access97)
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Fields data type (Access97)
- This topic has 3 replies, 3 voices, and was last updated 22 years, 6 months ago.
AuthorTopicWSready4data
AskWoody LoungerNovember 6, 2002 at 6:34 pm #379042Viewing 1 reply threadAuthorReplies-
WBell
AskWoody_MVPNovember 6, 2002 at 11:40 pm #629756First you make a backup of your database (or if it is split of the back-end database).
Then if you are paranoid, you make a second backup somewhere else.
Then you go into the database container window, and open the table in design mode, and change the field type and try to save the table. If you have non-numeric data in the field (anything not numbers or periods or commas, etc.) Access will complain and say it can’t save the data in the format you requested. Otherwise, it should be good to go at that point. -
WSHansV
AskWoody LoungerNovember 7, 2002 at 6:20 am #629795As you may have surmised from Wendell’s reply, the answer to “How do I change a field’s data type in a table in code?” is “You can’t”. When you change the data type interactively, Access is doing things behind the scenes you can’t do in code, at least not directly.
The Type property of a DAO Field object is read/write until the object has been appended to the Fields collection, after that it is read-only. So you can’t use DAO to change the field type of an existing field.To simulate the interactive behaviour in code, you’d have to do the following:
- Create a new field of type dbLong; give it a temporary name, and append it to the Fields collection.
- Execute an update SQL instruction that sets the value of the new field that of the old field (converted from string to long integer).
- Delete the old field.
- Rename the new field to the name of the old field.
If the text field is part of an index or relation, you’d have to do even more work…
-
WSready4data
AskWoody LoungerNovember 7, 2002 at 10:21 am #629814
-
Viewing 1 reply thread -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
hibernate activation
by
e_belmont
3 hours, 25 minutes ago -
Red Hat Enterprise Linux 10 with AI assistant
by
Alex5723
3 hours, 43 minutes ago -
Windows 11 Insider Preview build 26200.5603 released to DEV
by
joep517
6 hours, 47 minutes ago -
Windows 11 Insider Preview build 26120.4151 (24H2) released to BETA
by
joep517
6 hours, 49 minutes ago -
Fixing Windows 24H2 failed KB5058411 install
by
Alex5723
9 hours, 59 minutes ago -
Out of band for Windows 10
by
Susan Bradley
11 hours, 32 minutes ago -
Giving UniGetUi a test run.
by
RetiredGeek
18 hours, 29 minutes ago -
Windows 11 Insider Preview Build 26100.4188 (24H2) released to Release Preview
by
joep517
1 day, 2 hours ago -
Microsoft is now putting quantum encryption in Windows builds
by
Alex5723
1 day ago -
Auto Time Zone Adjustment
by
wadeer
1 day, 6 hours ago -
To download Win 11 Pro 23H2 ISO.
by
Eddieloh
1 day, 4 hours ago -
Manage your browsing experience with Edge
by
Mary Branscombe
8 hours, 51 minutes ago -
Fewer vulnerabilities, larger updates
by
Susan Bradley
19 hours, 47 minutes ago -
Hobbies — There’s free software for that!
by
Deanna McElveen
3 hours, 41 minutes ago -
Apps included with macOS
by
Will Fastie
1 hour, 33 minutes ago -
Xfinity home internet
by
MrJimPhelps
23 hours, 37 minutes ago -
Convert PowerPoint presentation to Impress
by
RetiredGeek
23 hours, 35 minutes ago -
Debian 12.11 released
by
Alex5723
2 days, 3 hours ago -
Microsoft: Troubleshoot problems updating Windows
by
Alex5723
2 days, 7 hours ago -
Woman Files for Divorce After ChatGPT “Reads” Husband’s Coffee Cup
by
Alex5723
1 day, 10 hours ago -
Moving fwd, Win 11 Pro,, which is best? Lenovo refurb
by
Deo
3 hours, 28 minutes ago -
DBOS Advanced Network Analysis
by
Kathy Stevens
3 days ago -
Microsoft Edge Launching Automatically?
by
healeyinpa
2 days, 14 hours ago -
Google Chrome to block admin-level browser launches for better security
by
Alex5723
12 hours, 28 minutes ago -
iPhone SE2 Stolen Device Protection
by
Rick Corbett
2 days, 19 hours ago -
Some advice for managing my wireless internet gateway
by
LHiggins
2 days, 2 hours ago -
NO POWER IN KEYBOARD OR MOUSE
by
HE48AEEXX77WEN4Edbtm
1 day, 4 hours ago -
A CVE-MITRE-CISA-CNA Extravaganza
by
Nibbled To Death By Ducks
3 days, 12 hours ago -
Sometimes I wonder about these bots
by
Susan Bradley
1 day ago -
Does windows update component store “self heal”?
by
Mike Cross
2 days, 22 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.