Quantcast
Viewing all articles
Browse latest Browse all 11508

Forum Post: Re: Updating data using recordsets

There are many different programming styles that will work for gINT Rules, below is one style. It took longer to write this description up than it took to create the code that works. Again, this is just one suggestion as to what might work for you.

I used GRA005 to create the skeleton code for the PopulateElevation procedure. Then, all I did was add my "code" to assign a value of 35 which is highlighted in yellow.

In addition, this follows the programming style as discussed in the gINT Rules manual and references an additional module called "auxillary procedures" and includes the Public Sub Main procedure.

The "PopulateElevation" procedure is then assigned to the "gINT Rules Procedure on Save" Table Event.

You can run the procedure while you are in the gINT Rules editor using the F5 command, which is sounds like you are already doing with your code.

 

'#LibInclude "auxillary procedures"

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 PopulateElevation
'*****************************************************
'17Apr2013 DK
'Description:
'  This procedure is used to populate the Elevation field with
'  a set value.
'*****************************************************

  Const s_Field_BoreholeID As String = "PointID"
  Const s_Field_Elevation As String = "Elevation"

  Dim dElevation As Double

  'Column positions of fields in the data array.
  Dim iPsBoreholeID As Integer
  Dim iPsElevation As Integer

  Dim lRow As Long

  Dim sBoreholeID As String
  '------------------------

  'Obtain pointers to the field data within the data array.
  If InitFieldsFnB(s_Field_BoreholeID, iPsBoreholeID, _
                   s_Field_Elevation, iPsElevation) _
  Then
    'One or more of the required fields missing from the table.
    Exit Sub
  End If

  With gINTRules.GridData
    For lRow = 1 To glNumRows
      sBoreholeID = gsDataA(iPsBoreholeID, lRow)

      dElevation = 35

      gsDataA(iPsElevation, lRow) = CStr(dElevation)
    Next lRow
  End With
End Sub


Viewing all articles
Browse latest Browse all 11508

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>