I am beginner learning the gINT Rules .
I am trying follow with the GR001 tutorial at page 97 (Code Samples) First Iteration in the book and apply it against a simple trial code project to see if I could get a sample text placed in the grid.
I have a table as shown in the image..
I have the following rules code [copy and pasteed from gr001 example but with my field and table names] and what I thought were assignment statements in that gr001:
Option Explicit 'Commonly used field names Public Const gs_Depth As String = "Depth" Public Const gs_HoleDepth As String = "HoleDepth" Public Const gs_PointID As String = "PointID" Public glNumRows As Long Public gsDataA() As String Public Function InitFieldsFnB(ParamArray pvFieldsV() As Variant) As Boolean '***************************************************** '05Aug2003 sc 'Description: ' Determine the positions of fields in the data array. ' If any or not found, report the missing field or fields and abort further ' code execution. 'Input: ' pvFieldsV(): Elements 0, 2, 4,... are the field names. 'Output: ' pvFieldsV(): Elements 1, 3, 5,... are the field positions. 'Returns: ' True if fields were not found, False if all were found. '***************************************************** Const s_FieldSeparator As String = ", " Dim iInd As Integer Dim iPsField As Integer Dim sMissingFields As String '------------------ InitFieldsFnB = False sMissingFields = "" With gINTRules.GridData For iInd = 0 To UBound(pvFieldsV) Step 2 iPsField=.FieldCol(CStr(pvFieldsV(iInd))) If iPsField Then pvFieldsV(iInd + 1) = iPsField Else sMissingFields = sMissingFields & _ s_FieldSeparator & _ pvFieldsV(iInd) End If Next iInd If Len(sMissingFields) Then sMissingFields = _ Mid$(sMissingFields, Len(s_FieldSeparator) + 1) MsgBox "The following field(s) are missing " & _ "from this table." & vbCrLf & _ Space$(5) & sMissingFields & vbCrLf & _ "Cannot perform the save checks " & _ "and calcs without it/them." & vbCrLf & _ "Data will be saved as-is.", _ vbOkOnly, "Field Checking" InitFieldsFnB = True End If End With End Function
'#LibInclude "Common" Option Explicit Public Sub Main With gINTRules.GridData 'Put the grid data into a working string data array. gsDataA=.DataArray glNumRows = UBound(gsDataA, 2) CallByName Me, gINTRules.ProcedureName, vbMethod 'Put the modified data array back into the input grid. .DataArray=gsDataA 'Success is True if there were no errors. gINTRules.Success=CBool(.ErrorCol=0) End With End Sub Public Sub Laboratory Dim iPsDepth As Integer Dim iPsConfining_Pressure As Integer Dim iPsDeviator_Stress As Integer Dim iPsMoisture_Content As Integer Dim iPsLiquid_Limit As Integer Dim iPsPlasticity_Index As Integer Dim iPsWet_Density As Integer Dim iPsComments As Integer Dim iPsPP As Integer Dim iPsM200 As Integer Dim iPsLab_Tech_Description As Integer Dim lRow As Long With gINTRules.GridData iPsDepth = .FieldCol("Depth") iPsConfining_Pressure = .FieldCol("Confining Pressure") iPsDeviator_Stress = .FieldCol("Deviator Stress") iPsMoisture_Content = .FieldCol("Moisture Content") iPsLiquid_Limit = .FieldCol("Liquid Limit") iPsPlasticity_Index = .FieldCol("Plasticity Index") iPsWet_Density = .FieldCol("Wet Density") iPsComments = .FieldCol("Comments") iPsPP = .FieldCol("PP") iPsM200 = .FieldCol("-200") iPsLab_Tech_Description = .FieldCol("Lab Tech Description") For lRow = 1 To glNumRows 'just trying to put the text into the Comments Field gsDataA(iPsComments, lRow) = "Test Data" Next lRow End With End Sub
The Tables are shown in the screen grab
Click image to get it to expand to show the fields I am working with ...
The error is in the line "CallByName Me, gINTRules.ProcedureName, vbMethod" .. when I try to run the code it says "(10091) ActiveX Automation: no such property or method. No Pre- or Post-process code specified for table LABORATORY"
Am I missing some hidden fields or key fields Do I need Point ID? Confused as to why it breaks. Also Dont think I need the field names check function at this point, right?
Maybe I need a gINTRules.GridData.DataValue (Col, Row) = "My testing text here"???
I wouldn't have run it as an AddIn, I use the AddIn option when I need to add a custom menu item for a client to facilitate, say, importing or exporting data. Many times you cannot just use a Correspondence File and the Import or Export command to import or export data. In many cases, the source file is not setup to allow the use of a Correspondence File and therefore a gINT Rule is needed to read the data from the source file and to then put the data in the appropriate tables in the gINT project database. The same can be true when exporting to a file.
This was great information.. I ran it via making it an AddIn and it worked as expected... It did not run from the IDE which I was using to try and test things. Thanks so much for your interest in this hurdle I was having.. Apparently you cannot run to test from the gint rules IDE
Hi Art,
I set the procedure to run on the "gINT Rules Procedure on Save" event, which is the most common and I assumed that was what you were wanting to do.
To test it, I just deleted a value in one of the fields in the first record which then triggers the "on save" event and then saved the changes. The "Comments" field was then populated with the "Test Data" text that you had hard coded into the procedure.
I then repeated that for a second record.
Answer Verified By: Art Koenig
DId you run from the IDE within the Sub Laboratory or did you fire it from a change tab or save on exit etc event..
I just copied your code examples into 2 new modules in a copy of the GR001 library file. I made no modifications to them.
I recognized that you were using a copy of the TX DOT project file so I copied the Laboratory table to a copy of the GR001 project file and added your additional fields.
The code works just fine the way you had written it so far.