|
-
Jul 28th, 2025, 04:20 PM
#1
Access Alter Column to Nullable
Altering a column to not nullable appears pretty straightforward. Altering a column that is required to be not nullable doesn't seem to be possible. There's a lengthy way around that, of course, since I could drop the column then re-add it (or include more steps to add a temporary column, copy values over, then drop the original, rename the new, and go from there.
That doesn't seem right. So, is there a means to make a non-nullable column nullable in an Access database using a query?
My usual boring signature: Nothing
 
-
Jul 30th, 2025, 10:55 AM
#2
Re: Access Alter Column to Nullable
you could try...
Code:
ssql = " Alter Table yourTable Alter Column [myColumn]TEXT Null;"
'the Field myColumn is TEXT
EDIT: just tried that, and sorry that will not work
back to the drawing board
EDIT2: this will work, I used DAO in .NET
Code:
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim AccessDatabaseEngine As New Microsoft.Office.Interop.Access.Dao.DBEngine()
Dim AccessDatabase As Microsoft.Office.Interop.Access.Dao.Database
Try
AccessDatabase = AccessDatabaseEngine.OpenDatabase("E:\Adressen.mdb")
AccessDatabase.TableDefs("YourTable").Fields("yourColumn").Required = False
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
AccessDatabase.Close()
End Try
End Sub
Last edited by ChrisE; Jul 30th, 2025 at 11:22 AM.
to hunt a species to extinction is not logical !
since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.
-
Jul 30th, 2025, 01:22 PM
#3
Re: Access Alter Column to Nullable
I'm not going DAO for this.
In fact, I'm not doing anything, because after a bit of study, I realized that the field was never used in any way and no longer has any relevance, so I dropped it entirely. That solved the problem, but did not answer the question, so I'm leaving it open. I did try your first suggestion before I posted this, as it seemed like it should work. As you noted, it did not. I also found the DAO solution, but that's massive overkill to haul DAO out of it's grave for something like this.
My usual boring signature: Nothing
 
-
Feb 9th, 2026, 11:07 AM
#4
Re: Access Alter Column to Nullable
Yeah... they even say this on their page : https://learn.microsoft.com/en-us/of...oft-access-sql
"The Microsoft Access database engine does not support the use of ALTER TABLE, or any of the data definition language (DDL) statements, with non-Microsoft Access databases. Use the DAO Create methods instead."
-
Feb 10th, 2026, 02:49 AM
#5
Re: Access Alter Column to Nullable
 Originally Posted by gigemboy
Yeah... they even say this on their page : https://learn.microsoft.com/en-us/of...oft-access-sql
"The Microsoft Access database engine does not support the use of ALTER TABLE, or any of the data definition language (DDL) statements, with non-Microsoft Access databases. Use the DAO Create methods instead."
What's that got to do with the original issue?
MS Access-ENGINE doesn't support ALTER TABLE for NON-Access-Databases (e.g. if you have linked NON-Access-Tables)
Shaggy, have you thought about it that a "NOT NULL" actually is a CONSTRAINT (like UNIQUE)?
Remember this: https://www.vbforums.com/showthread....ove-Constraint
EDIT: Found this: https://stackoverflow.com/questions/...lumn-in-access
Seems you're out of luck.
Open that Access-DB in Access itself, go to the designer, and change the Required Prop for the Column there.
It is as it is....
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Feb 10th, 2026, 09:11 AM
#6
Re: Access Alter Column to Nullable
Probably nothing now that I re-read. But Shaggy is still prob out of luck with this one: https://stackoverflow.com/questions/...lumn-in-access
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|