Bookmark this page: Add ArcObjects   to Yahoo MyWeb Add ArcObjects   to Google Bookmarks Add ArcObjects   to Windows Live Add ArcObjects   to Del.icio.us Digg ArcObjects  ! Add ArcObjects   to Netscape
  •  
  • Subject
  • Author
  • Date
If you were  Registered and logged in, you could reply and use other advanced thread options
Posted by Simon on July 18, 2007, 5:20 am
Ok, writing a tool that lets end-user apply weightings (via slider
bars) which in turn changes the attributes (calculates new values).
Thats fine. What Id like to do is SAVE the weighting factors applied
into a stand-alone table so that they can be recalled next time the
session is opened.

Now, im fairly new to VBA but the code below is nearly there - A user
can move slider bars (in code below, only one weighting is there for
testing purposes) which populates the variable EcS1_Wf
This is then written to the stand-alone table (WeightFactors).
However, it creates a new record everytime - I only need there to be
one record in the table (i.e. the Last sessions weightings)

How would you tweak the code to apply this?
Do you delete the row out at the beginning? Or change it so that
instead of inserting a new row, it updates a row?

Either way, bit stuck on how to change code. Any tips would be
nice...




Dim pWorkspaceFactory As IWorkspaceFactory
Dim pFeatWorkspace As IFeatureWorkspace

Set pWorkspaceFactory = New AccessWorkspaceFactory
Set pFeatWorkspace = pWorkspaceFactory.OpenFromFile(strDBpath, 0)

Set pWtFacTable = pFeatWorkspace.OpenTable("WeightFactors")

'Create a query filter to select row
Dim pQf As IQueryFilter
Set pQf = New QueryFilter

Dim pFcursor1 As ICursor
Set pFcursor1 = pWtFacTable.Search(Nothing, False)

'Get the rows that match the query filter
Dim pRow As IRow
Set pRow = pFcursor1.NextRow

If pRow Is Nothing Then

MsgBox "Please check format of weighting tables - process exiting !"
Exit Sub

Else
' Writing selected weighting factors to table

Dim pWgtInsCursor As ICursor
Set pWgtInsCursor = pWtFacTable.Insert(False)
Dim pWgtRowBuff As IRowBuffer

'Find fields
EcS1Wf_db = pWtFacTable.FindField("EC1_WSF")

'Write Fields to table
Set pWgtRowBuff = pWtFacTable.CreateRowBuffer
With pWgtRowBuff
.Value(EcS1Wf_db) = Me!EcS1_Wf.Value
End With

pWgtInsCursor.InsertRow pWgtRowBuff
End If


MsgBox "Finished Calculations", vbInformation

Set pMxDoc = ThisDocument
pMxDoc.ActiveView.Refresh


frmWtgs.Hide