I'm trying to make a rule that will change field properties (required, read only) and can't figure out how the correct usage. Any pointers?
it will eventually be part of if statements but for now...
I get ActiveX automation object var is Nothing
Sub mainDim depth As Fielddepth.Required = TrueEnd Sub
Hi Brett,
Please see the gINT Rules Manual, as well as the gINT Rules Samples. I'd also recommend checking out the videos under the GRA005 sample for an overview of gINT Rules.
Off the top of my head, I don't think you can set field properties like you are trying to do above. If you want certain fields to be conditionally required, etc. you would typically write some validation code to see if the field is empty (such as in an On Save event Rule) and then raise an error/warning. There will be examples in the Manual/Samples.
Hi Brett
These are DAO field properties, you loop through the properties for a field until you find the relevant one, and set the value.
docs.microsoft.com/.../field-object-dao
regards
Phil Wade
Phil WadeDatgelBentley Channel Partner and Developer PartnerE: phil.wade@datgel.com | T: +61 2 8202 8600 & +65 6631 9780
Get the most out of gINT with Datgel Tools.
DAO was what was needed.
This finally worked for me to get a property change from No to Yes.
...Now I just need to get the change to save it's lost if I click to another table or enter new data.and find where the read-only property lives (I don't spot it when I loop through field properties)
Function test Dim fld As DAO.Field Dim stable As String Dim sfield As String Dim prop As DAO.Property stable="Point" sfield="Location" Set fld = gINTRules.CurrentProject.TableDefs(stable).Fields(sfield) Debug.Print fld.Properties("Required").Value ''''''-1 is true fld.Properties("Required") ="-1" Debug.Print gINTRules.CurrentProject.TableDefs(stable).Fields(sfield).Properties("Required").Value End Function
Before going further, will it cause problems changing properties within an enterprise database? Can some projects have data marked required or read-only and other projects have data not be required or read-only for the same field?
For SQL Server, the field properties are stored in SQL Server db table WH_ColumnProperties. You can read and write using SQL select and update statements.