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
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
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
-
Windows hosting exposes additional bugs
by
Susan Bradley
19 minutes ago -
No more rounded corners??
by
CWBillow
2 hours, 43 minutes ago -
Android 15 and IPV6
by
Win7and10
1 hour, 24 minutes ago -
KB5058405 might fail to install with recovery error 0xc0000098 in ACPI.sys
by
Susan Bradley
12 hours, 39 minutes ago -
T-Mobile’s T-Life App has a “Screen Recording Tool” Turned on
by
Alex5723
15 hours, 21 minutes ago -
Windows 11 Insider Preview Build 26100.4202 (24H2) released to Release Preview
by
joep517
9 hours, 56 minutes ago -
Windows Update orchestration platform to update all software
by
Alex5723
22 hours, 41 minutes ago -
May preview updates
by
Susan Bradley
10 hours, 4 minutes ago -
Microsoft releases KB5061977 Windows 11 24H2, Server 2025 emergency out of band
by
Alex5723
1 hour, 39 minutes ago -
Just got this pop-up page while browsing
by
Alex5723
14 hours, 52 minutes ago -
KB5058379 / KB 5061768 Failures
by
crown
11 hours, 56 minutes ago -
Windows 10 23H2 Good to Update to ?
by
jkitc
1 hour, 16 minutes ago -
At last – installation of 24H2
by
Botswana12
1 day, 14 hours ago -
MS-DEFCON 4: As good as it gets
by
Susan Bradley
1 hour, 15 minutes ago -
RyTuneX optimize Windows 10/11 tool
by
Alex5723
2 days, 2 hours ago -
Can I just update from Win11 22H2 to 23H2?
by
Dave Easley
50 minutes ago -
Limited account permission error related to Windows Update
by
gtd12345
2 days, 15 hours ago -
Another test post
by
gtd12345
2 days, 16 hours ago -
Connect to someone else computer
by
wadeer
2 days, 10 hours ago -
Limit on User names?
by
CWBillow
2 days, 13 hours ago -
Choose the right apps for traveling
by
Peter Deegan
2 days, 3 hours ago -
BitLocker rears its head
by
Susan Bradley
1 day, 11 hours ago -
Who are you? (2025 edition)
by
Will Fastie
1 day, 10 hours ago -
AskWoody at the computer museum, round two
by
Will Fastie
2 days, 5 hours ago -
A smarter, simpler Firefox address bar
by
Alex5723
3 days, 2 hours ago -
Woody
by
Scott
3 days, 11 hours ago -
24H2 has suppressed my favoured spider
by
Davidhs
1 day, 11 hours ago -
GeForce RTX 5060 in certain motherboards could experience blank screens
by
Alex5723
4 days, 1 hour ago -
MS Office 365 Home on MAC
by
MickIver
3 days, 19 hours ago -
Google’s Veo3 video generator. Before you ask: yes, everything is AI here
by
Alex5723
4 days, 15 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.