Satheesh
Satheesh

Reputation: 656

How to remove existing validation rule in mdb from visual basic

I want to remove existing ValidationRule property which resides in the TABLE from vba programatically. I am unaware the constraint name too.

enter image description here

I opted to print table informations. So that i can add the constraint name in alter statement. Please let me know if u feel the question is not clear

Upvotes: 1

Views: 715

Answers (1)

HansUp
HansUp

Reputation: 97101

You can examine and/or modify a field's ValidationRule property by referencing the field name in the table's Fields collection.

Here is a sample Immediate window session ...

' display existing rule
? CurrentDb.TableDefs("tblFoo").Fields("a_number").ValidationRule
<999
' discard rule
CurrentDb.TableDefs("tblFoo").Fields("a_number").ValidationRule = ""
' verify rule gone
? CurrentDb.TableDefs("tblFoo").Fields("a_number").ValidationRule

' that last command printed an empty string

The ValidationRule property is not implemented as a named constraint and it can not be altered with a SQL DDL statement.

Upvotes: 2

Related Questions