PC Review


Reply
Thread Tools Rate Thread

Change column to Required = no and Drop all table relationships

 
 
Jim
Guest
Posts: n/a
 
      5th May 2010
What is the command to alter a 'required' column to be not required?

How do I drop all of the table relationships in a database if i do not know
the names assigned to the relationships?

Thanks in advance for the help,

Jim
 
Reply With Quote
 
 
 
 
Dirk Goldgar
Guest
Posts: n/a
 
      5th May 2010
"Jim" <(E-Mail Removed)> wrote in message
news:8F69F31B-5BB2-454A-9A0D-(E-Mail Removed)...
> What is the command to alter a 'required' column to be not required?


You can use DAO. Here's a quick & dirty version:

CurrentDb.TableDefs("YourTableName").Fields("YourFieldName").Required =
False

> How do I drop all of the table relationships in a database if i do not
> know
> the names assigned to the relationships?


Do you want to drop *all* relationships of all tables? Or just all
relationships of a particular table?

'------- start of code ("air code") ------
Sub DropAllRelationships()

' Drop all relationships in the current database.
' Are you sure you want to do this?

Dim db As DAO.Database
Dim I as Long

Set db = CurrentDb

With db.Relations
For I = .Count - 1 To 0
.Delete .Item(I).Name
Next I
End With

End Sub

Sub DropTableRelationships(TableName As String)

' Drop all relationships involving a given table.

Dim db As DAO.Database
Dim I as Long

Set db = CurrentDb

With db.Relations
For I = .Count - 1 To 0
If .Item(I).Table = TableName _
Or .Item(I).ForeignTable = TableName _
Then
.Delete .Item(I).Name
End If
Next I
End With

End Sub
'------- end of code ------

The above is all air code, but should be close to correct. Warning -- use
with care, and have a backup!

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change Cell Data of a Required Column jonathan Microsoft Excel Programming 2 9th Jan 2004 11:44 AM
read-only user can change table relationships? Gabe Microsoft Access Security 1 17th Oct 2003 09:36 AM
alter table, create table, drop column John Microsoft Access 1 7th Oct 2003 05:57 PM
required relationships for a multi table form Jeff Elliott Microsoft Access ADP SQL Server 0 8th Aug 2003 10:07 PM
Re: Help Required with Table Relationships Kevin @ 3NF Microsoft Access Database Table Design 0 28th Jul 2003 01:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:43 PM.